Setting up rails - 304 Not Modified - ruby-on-rails

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.

Related

Setting up ruby on rails 500 Internal Server Error

I decided to learn ruby on rails today. I did:
gem install rails
rails new <name>
cd <name>
rails server
Just like http://rubyonrails.org/download/ said to, and everything looked fine until I went to localhost:3000 on chrome I got "ERR_CONNECTION_REFUSED" and got nothing server side. Then I did:
wget localhost:3000
and got this client side (the terminal window running wget):
--2016-01-16 23:08:43-- http://localhost:3000/
Resolving localhost... fe80::1
Connecting to localhost|fe80::1|:3000... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2016-01-16 23:08:43 ERROR 500: Internal Server Error.
and this server side (the side running rails server):
Started GET "/" for fe80::1%o0 at 2016-01-16 23:08:17 -0500
sorry if this is obvious I am a web scrub :)
EDIT:
when I launch it says "WEBrick::HTTPServer#start: pid=35515 port=3000" so I assume that means it's on the right port
EDIT:
development.log:
Started GET "/" for fe80::1%lo0 at 2016-01-16 23:08:17 -0500
Started GET "/" for fe80::1%lo0 at 2016-01-16 23:08:33 -0500
Started GET "/" for fe80::1%lo0 at 2016-01-16 23:08:43 -0500
I had a similar problem. Open your hosts file and see if there is a line like this:
sudo vi /etc/hosts
fe80::1%lo0 localhost
Commenting it out or removing should help.
By default running rails server will start in development mode. So I would expect a log folder to be created with further details:
gem install rails
rails new <name>
cd <name>
rails server
Than you should be able to view the error in the log
<project folder>
cd log
vi development.log

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

RoR - Not loading or requesting -any- assets in development mode

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

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?

started rails server, now what?

I'm new to ruby on rails and trying to start learning. I'm developing on mac os x. I updated rubygems and rails.
I've started the server and have gotten the rails welcome page but my terminal is hung up. If i quit the terminal the server ends. Here is the text in my terminal right now. the cursor is on a new row directly under the last line so anything i type doesn't do anything if entered(except go to new line).
Is there a command i'm missing to start creating controllers and views in the terminal?
Last login: Thu Dec 15 18:11:43 on ttys000
You have mail.
Joe-Blows-MacBook-Pro:~ joeblow$ cd desktop/code/blogg
Joe-Blows-MacBook-Pro:blogg joeblow$ rails server
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-15 18:26:35] INFO WEBrick 1.3.1
[2011-12-15 18:26:35] INFO ruby 1.8.7 (2010-01-10) [universal-darwin10.0]
[2011-12-15 18:26:35] INFO WEBrick::HTTPServer#start: pid=25823 port=3000
Started GET "/assets/rails.png" for 127.0.0.1 at Thu Dec 15 18:26:39 -0600 2011
Served asset /rails.png - 304 Not Modified (1ms)
When developing Rails applications, you'll typically have several terminals open at once.
This terminal is just for watching the standard output logging from the server. You'll probably want another terminal open with tail -F /path/to/logs/logs to see all the logs at once, and another terminal open for your editing, rails generate ..., git, etc. uses. You might have one more open for script/console to give you an irb-alike interface "inside" your application.
Open your browser and go to http://127.0.0.1:3000
If you want to be able to use the console run
rails server &

Resources