Setting up ruby on rails 500 Internal Server Error - ruby-on-rails

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

Related

rails ember-cli No route matches [GET] > "/javascripts/emberFrontend/vendor.js"

I am new to Ember and I'm trying to understand how the asset building works.
I have an existing Rails project that is in the middle of conversion to Ember, with ember-cli.
ember 1.13
ruby 2.1.6
rails 4.1.6
I keep getting these errors when trying to access ember pages, and I'm trying to isolate when, and what causes them:
Started GET "/javascripts/emberFrontend/vendor.js" for 127.0.0.1 at
2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/vendor.js"):
...
Started GET "/javascripts/emberFrontend/ember-frontend.js" for
127.0.0.1 at 2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/ember-frontend.js"):
for example, I take a page that is rendering fine and logs:
Started GET
"/assets/emberFrontend/vendor-b0892280be71c70102741f9d7feb0532.js" for
127.0.0.1 at 2015-12-28 17:53:15 +0200
Started GET
"/assets/emberFrontend/ember-frontend-affc24729a1c2e1a0a6a56334d2bb16a.js"
for 127.0.0.1 at 2015-12-28 17:53:15 +0200
And I make a change in the template code from:
<li class="reportsTab"><a href={{urls.reports}}>Reporting</a></li>
to:
<li>{{#link-to "merchant.reports"}}Reporting{{/link-to}}</li>
In order for one of the page tabs to direct to the ember code instead of the old one, similar to other changes made on that page. This change causes the errors above, and the browser page is blank.
What is puzzling me is that if I revert the change while the rails server is running, and then restart it - it doesn't stick, but if I stop the server, than make the change and rerun it, it does.
Clearly I am missing something in understanding how the ember server is building the assets, but I can't figure it out from any guides.
Also (and possbily related), my */emberFrontend/tmp directory doesn't clean.
Turned out my machine is to slow.
I changed the timeout in /config/initializers/ember.rb to 60
c.app :emberFrontend, path: Rails.root.join('emberFrontend').to_s, build_timeout: 60

Filter chain halted as force SSL rendered or redirected

So my app in production has totally crashed with this message:
Filter chain halted as #<Proc:0x007f766547ea18#/app/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/force_ssl.rb:65> rendered or redirected
I've done some research online and so far this seems to happen mostly in local dev mode when the port is lost. But I'm not sure why this would be happening in my Heroku app... for context the code has not changed, and it was working fine as of 30 minutes ago. I'm using CloudFlare, but I checked that the bare your-app-name.herokuapp.com is also broken with the same error.
Any help appreciated!
I got this same error but on my development environment in rails 4.0 (because of an controller with force_ssl on it).
I solved this using the thin web server with ssl support, like so:
Add the thin gem to my Gemfile on the development group:
group :development do
gem 'thin'
end
Run bundle install on your termnal:
bundle install
Start thin with ssl support on terminal:
bundle exec thin start --ssl
Access the page via https on your web browser:
The protocol need to be https at the beginning, otherwise you can get an empty response. (ERR_EMPTY_RESPONSE)
https://localhost:3000/
If you get your connection refused (ERR_CONNECTION_REFUSED) you'll need to define the loopback ip address on the server params:
bundle exec thin start --ssl -a 127.0.0.1
You'll get an privacy error, jus click on Advanced and on Go to localhost (not safe)
Sorry my image is in pt-br:
It's done! You'll get an self-signed https connection on localhost in development mode ;)

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

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