# A Mongrel of an Error

**URL:** <https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818>\
**Category:** Rails\
**Created:** [July 9, 2009, 5:49pm UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818 "2009-07-09T17:49:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [July 9, 2009, 5:49pm UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818/1 "2009-07-09T17:49:57Z")

</div>

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-](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”.

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](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](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  
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/  
session/cookie\_store.rb:91:in `ensure_secret_secure' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session/cookie_store.rb:60:in `initialize’  
…

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [July 9, 2009, 5:58pm UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818/2 "2009-07-09T17:58:08Z")

</div>

On Jul 9, 2009, at 8:49 AM, shusseina wrote:

> Viewing [http://localhost:3000/stories](http://localhost:3000/stories) in my browser should display the
> 
> effect. \*  
> \*\* 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…

> **[/!\\ FAILSAFE /!\\ handling with rails versions prior to 2.3](https://billkirtley.wordpress.com/2009/03/03/failsafe-handling-with-rails/)**
>
> If you are running an application using a version of Ruby on Rails prior to 2.3 (including 2.2.2), and serving it with mongrel, you are at risk of serving up incorrect internal server pages. Patch …

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [July 9, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818/3 "2009-07-09T18:03:59Z")

</div>

On Thu, Jul 9, 2009 at 11:49 AM, shusseina[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Viewing [http://localhost:3000/stories](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.

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [July 10, 2009, 3:38am UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818/4 "2009-07-10T03:38:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [July 10, 2009, 5:43am UTC](https://www.ruby-forum.com/t/a-mongrel-of-an-error/171818/5 "2009-07-10T05:43:34Z")

</div>

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,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
