RoR - Not loading or requesting -any- assets in development mode - ruby-on-rails

I'm brand new to Rails development and in a bit of a mess! I've been given a codebase and none of the assets aren't being referenced in the HTML. No failed network requests, they simply aren't being included in the mark-up! They are present there when I attempt to access them directly using their URL though.
As a comparison - my colleagues system ends up with around 30 or so requests and the end result is fully styled. However I have no styling and just the base mark-up.
I've done a fair amount of reading and checked my config, checked that I'm running in development mode and so on. I'm really stumped!
For what it's worth, I'm currently working in a cross-platform team environment where there are developers using Linux, Windows and Mac OS X. No one has these issues; and I'm pretty sure the other developer using Mac OS X has his set-up exactly the same as mine!
The source code was acquired from the same git repository as others, and it's definitely up to date. Below is the output from rails: note no errors.
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /******************/abstract_store.rb:28:in `initialize'.
[2013-04-17 21:20:55] INFO WEBrick 1.3.1
[2013-04-17 21:20:55] INFO ruby 2.0.0 (2013-02-24) [x86_64-darwin12.3.0]
[2013-04-17 21:20:55] INFO WEBrick::HTTPServer#start: pid=22421 port=3000
Started GET "/" for 127.0.0.1 at 2013-04-17 21:21:05 +0100
Processing by AccountsController#home as HTML
Completed 401 Unauthorized in 6ms
Started GET "/users/sign_in" for 127.0.0.1 at 2013-04-17 21:21:05 +0100
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.erb (1.5ms)
Rendered devise/sessions/new.html.erb within layouts/application (10.0ms)
Rendered layouts/_navigation.html.erb (1.0ms)
Rendered layouts/_messages.html.erb (0.3ms)
Completed 200 OK in 776ms (Views: 86.5ms | ActiveRecord: 647.5ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-04-17 21:21:06 +0100
Served asset /application.js - 304 Not Modified (1ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-04-17 21:21:06 +0100
Served asset /application.css - 304 Not Modified (1ms)
Note: The application.js just appears to have 5 //=require directives; and the application.css has mainly comments with a few simple rules - nowhere near what should be there.

My solution is: install ruby version 1.9.3 and set this version as default. Restart your computer. Then install rails 3.2.6. Then clone a new repository for your source code (Do not reuse the one that is having error). Run bundle install.
Before this, I also tried to install ruby 1.9.2 with rvm but it does not work. Then I tried with ruby 1.9.3 and it works.

I've had a similar problem in a previous project. Personally I would try what everett1992 said because if that corrects the problem, it's probably best. But what I've used when that didn't work was the line
config.assets.prefix = "/assets_dev"
to my development.rb file.
Now, assets_dev is not a real directory, I never created it. But it forced rails to look there, and then when it doesn't see it, rails will load your assets from the default location as should happen in rails.
Like I said, it might work, but I'm sure its not the best way. I too work on OS X on cross platform projects with others, and I've yet to figure out why this sometimes happens.

I'm using mac os x 10.6.8 and I have the same problem, and tried all the solutions above. Nothing work.
Including:
1> update gem
2> remove rvm, reinstall rvm, ruby, rails...
3> and make configuration as config(dot)assets(dot)prefix = "/assets_dev"
By the way, I've checked GoogleChrome console, and realize that, within application(dot)css, there is still statement as below:
require_self
require_tree.
Which mean these reference does not works at all.
The same things happen to application(dot)js
P/S: I'm using rails 3.2.6

Related

Rails on EC2 - Puma responds, but page never loads on browser

Firstly, cheers! This is my first post here on Stack Overflow, I'll try not to do anything silly :). I've spent the last 3 days banging my head against this issue and googleing away, but never really found a solution, however basic it may be.
I've set up a fresh EC2 instance (running Ubuntu 16.04) and created a new Rails (v 5.1.6) app with a simple scaffold:
rails new test_app
cd test_app
At this point, Rails complained that I had to install the 'listen' gem, which I did (v 3.1.5). I then proceeded as follows:
rails g scaffold article title:string
rails db:create
rails db:migrate
So far so good. I then went on to configure AWS's security groups and properly allow TCP connections through port 3000. I'm currently using Puma (v 3.7) as a server.
Here's whats bugging me: I then ran
rails server
and tried to connect to my EC2 through Chrome on port 3000. Turns out that I was able to get to the usual "You're on Rails" page, no problem, but when I tried to get to any other pages, say /articles or /articles/new, I got a positive response from the server in the console:
Started GET "/articles"
Processing by ArticlesController#index as HTML
Rendering articles/index.html.erb within layouts/application
Article Load (0.7ms) SELECT "articles".* FROM "articles"
Rendered articles/index.html.erb within layouts/application (47.3ms)
Completed 200 OK in 3912ms (Views: 3807.5ms | ActiveRecord: 1.5ms)
But the browser keeps waiting forever for a response. I also tried accessing the URL through curl and got no response as well. I'd appreciate if anyone could let me know how stupid a mistake I'm making here.
Thanks,
Márcio
Firstly, cheers you explained your problem very well
when you deploying your app on EC2 then this isn't the right way to do but still it should give you response in browser. Please make sure your port 3000 isn't blocked. Go to network interface -> select your instance carefully -> in front of Security groups check your inbound rules and make sure port 3000 is open
Above explanation is just to answer whatever you are trying to do. Although this should not be the proper way. Proper way should (in short ) be running your ruby on rails application with a rack server (puma, thin, etc) behind a web server Apache or Nginx .

Rails Server-- clearing unwanted logs in rails server

when ever I am using my app in local machine I have to on the server
$rails server
each time I do something in my app in the browser all the assets, jquery logs appear in the terminal like
Started GET "/assets/jquery.ui.core.css?body=1" for 127.0.0.1 at 2013-10-11 12:38:44 +0530
....
.....
and so on like this .
If i dont want to see them in my logs each time what should I do?
Am new to Linux
Possible this How to disable logging of asset pipeline (sprockets) messages in Rails 3.1? is the answer your question.
Briefly, you can use this gem: https://github.com/evrone/quiet_assets

JQuery File Upload with Ruby on Rails/brackets

I was interested in JQuery File Uploader on Ruby on Rails and tried to use this applicationm and this one
I have made a new rails project with "rails new fily" and have copied and pasted all files in my fily-folder that they have in this application. I run bundle install and rake db:migrate but by opening localhost:3000/picture the only thing that I saw was: [], brackets and nothing more. What can be the reason?
In terminal I see following:
Started GET "/pictures" for 127.0.0.1 at 2012-10-21 23:21:13 +0200
Processing by PicturesController#index as HTML
Picture Load (0.2ms) SELECT "pictures".* FROM "pictures"
Completed 200 OK in 3ms (Views: 1.6ms | ActiveRecord: 0.2ms)
[2012-10-21 23:21:14] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
I would be grateful if somebody helps me
PS. I have found as well some very strange hidden file there:
.rvmrc
with a content:
rvm use ruby-1.9.3-p194#fily
What should that mean?
The .rvmrc file is used by RVM, the Ruby Version Manager, which allows multiple versions of Ruby to coexist on a machine, and allows you to specify which ones to use. The .rvmrc tells RVm to use the specified version of ruby, although it seems to me that the person who made that git repo used his own compiled from source. I don't think deleting it will bring any harm.
Looking at the code, (haven't got ruby on this machine yet so I can't test it to be sure), it seems as though you shouldn't be accessing /pictures. Instead, just access / (which calls and renders the pictures#new controller).

Rails Server is not finishing inside terminal

I am new to Rails and working my way through RonR3 Tutorial. Everything has worked perfectly except by page 59
$ rails generate scaffold Micropost content: String user_id:integer.
When I try to run rails s or rails server my terminal application never seems to end. When I ctrl-c to shut down the server after 10+ hours the site can not be found on localHost. Any help would be much appreciated.
Everything seems to stall out around:
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /users.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
After this the terminal just sits there doing nothing...
With programs run from the terminal, they will run there unless they stop or have a daemon option. When you press ctrl-c, the rails webbrick server stops, so of course localhost won't show anything.
When the server is sitting there, it's waiting for a user to visit the site. It won't render views, for example, unless there's a request to render views.
If you want to run the webserver while still using the same terminal window, you need to run rails s as a daemon (background process). Instead, run the command as rails s -d which will "detach" the server process.
On a side-note, why not open multiple terminal windows, if your operating system has a GUI/Window Manager. I normally keep three terminal windows open to run the server, make git commits, check rake routes, etc.
Related Question: Running Webrick server in background?

Setting up rails - 304 Not Modified

I am newbie trying to learn some code. I am following the tutorial on http://guides.rubyonrails.org/getting_started.html
I am up to the point where I've gotten the welcome aboard message at localhost:3000, the last command I typed into my OSX terminal was "rails server"
The server spit out some info and at the end I got this...
Started GET "/assets/rails.png" for 127.0.0.1 at Fri Jan 27 12:44:36
-0500 2012 Served asset /rails.png - 304 Not Modified (2ms)
Started GET "/assets/rails.png" for 127.0.0.1 at Fri Jan 27 12:48:29
-0500 2012 Served asset /rails.png - 304 Not Modified (0ms)
Now the terminal prompt is not coming up...not sure how to fix or what I should do? Thanks to anyone who can help!
When you type in rails server (or rails s for short) the server starts running in that terminal window. This is a good thing. It means that there was no critical error at start up and rails will proceed by showing you a log of what's happening in your app - what resources it's serving, how long does it take, what views is it rendering, what database queries is it running, etc.
To proceed you can either kill the server by pressing control-C or simply open up a new terminal tab by pressing command-T and work from there and you can always switch to the first tab to look at the log if needed. With rails you usually don't need to restart the server so you can usually just keep it running in a tab in your terminal (an exception to that is when editing stuff in config or your Gemfile).
The server runs until you end it by typing Control+C. What it does is turns your computer in to a web server, and allows you to look at your website by going to http://localhost:3000 (by default this is the webport). There is nothing wrong with your computer or program. The server will show you a log of what it's doing while you navigate your website.
The 304 Not Modified is just telling you that when it went to fetch something, it knows it's done it before and the file was not modified. This is usually true of static assets, like images.

Resources