A Mongrel of an Error

I'm a Rails newbie (and a Ruby newbie for that matter). I am working my way through the book href="http://www.amazon.com/Simply-Rails-2- Patrick-Lenz/dp/0980455200/ref=sr_1_1? ie=UTF8&s=books&qid=1247152951&sr=8-1">"Simply Rails 2"</a>.

I have generated the model and controller parts of the sample app, at which point the author instructs the reader to start the web server and view the app with their browser.

Viewing http://localhost:3000/stories in my browser should display the file app/views/stories/index.html.erb, but instead displays the following error:

Status: 500 Internal Server Error Content-Type: text/html 500 Internal Server Error

Any ideas what might be causing this error?

Please see the partial output from the server below:

=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment...

I'm a Rails newbie (and a Ruby newbie for that matter). I am working my way through the book href="http://www.amazon.com/Simply-Rails-2- Patrick-Lenz/dp/0980455200/ref=sr_1_1? ie=UTF8&s=books&qid=1247152951&sr=8-1">"Simply Rails 2"</a>.

I have generated the model and controller parts of the sample app, at which point the author instructs the reader to start the web server and view the app with their browser.

Viewing http://localhost:3000/stories in my browser should display the file app/views/stories/index.html.erb, but instead displays the following error:

Status: 500 Internal Server Error Content-Type: text/html 500 Internal Server Error

Any ideas what might be causing this error?

Please see the partial output from the server below:

=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment...

*******************************************************************      * config.breakpoint_server has been deprecated and has no effect. *

*******************************************************************

** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel 1.1.4 available at 0.0.0.0:3000 ** Use CTRL-C to stop. /!\ FAILSAFE /!\ Fri Jul 10 01:07:17 +1000 2009 Status: 500 Internal Server Error

A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" } in config/environment.rb

Did you do what it asks here?

If that doesn't help, see this for more info maybe...

Viewing http://localhost:3000/stories in my browser should display the file app/views/stories/index.html.erb, but instead displays the following error:

Status: 500 Internal Server Error Content-Type: text/html 500 Internal Server Error

Any ideas what might be causing this error?

...

Status: 500 Internal Server Error A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" } in config/environment.rb

Well, it's telling you how to fix it. You need to put something like

  config.action_controller.session = {       :session_key = "-myapp_session", # where myapp should be the name of your application instead of myap       :secret => "Some Random String at least 30 characters long, usually a long hexadecimal string"   }

somewhere inside the intializer block (which begins with) Rails::Initializer.run do |config|

inside config/environment.rb

You can and probably should use rake secret to generate the secret.

Thanks guys. I generated the secret string using rake secret and added the code to config/environment.rb and that error has now disappeared.

It seems the error came about because I started coding the app under Rails 1.2.6 and then upgraded to Rails 2.0.2 to be in line with the version used by the Simply Rails 2 book.

As a newbie I don't fully understand what rake can be used for, but I'm sure I'll learn soon enough.

Thanks again.

shusseina wrote: [...]

It seems the error came about because I started coding the app under Rails 1.2.6 and then upgraded to Rails 2.0.2 to be in line with the version used by the Simply Rails 2 book.

The current version is 2.3.2. I *strongly* recommens that you use that to learn on, not 2.0.2.

As a newbie I don't fully understand what rake can be used for, but I'm sure I'll learn soon enough.

Rake is designed to automate tasks. As you work with Rails, you will find that there are many common maintenance tasks that are generally automated by Rake (type "rake -T" for a list).

Thanks again.

Best,