# Activating Active\_Record\_Store session kills the app

**URL:** <https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835>\
**Category:** Rails\
**Created:** [February 21, 2010, 2:09pm UTC](https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835 "2010-02-21T14:09:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djtal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@djtal](https://www.ruby-forum.com/u/djtal)\
**Post date:** [February 21, 2010, 2:09pm UTC](https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835/1 "2010-02-21T14:09:33Z")

</div>

Hi!

I’m working on my first Rails (2.3.5) app and I’m experimenting with  
activating the Active Record Store after running into the 4K limit of  
the Cookie Store (I don’t really know how I ended up filling the cookie  
store, I didn’t put that much in there!).

I didn’t do much:

1. rake db:sessions:create
2. rake db:migrate

=\> Sessions table got created

1. added “config.action\_controller.session\_store = :active\_record\_store”  
to environment.rb

And now I can’t even start Mongrel!

“2540”  
=\> Booting Mongrel  
=\> Rails 2.3.5 application starting on [http://127.0.0.1:3000](http://127.0.0.1:3000)  
F:/Programming/Ruby/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/middleware\_stack.rb:98:in  
`insert\_after’: You have a nil object when you didn’t expect it!  
(NoMethodError)  
You might have expected an instance of Array.  
The error occurred while evaluating nil.+

Also, if I try to run a rake task, such as a db:migrate, I get a similar  
error:

> rake db:migrate  
> (in F:/Programming/Ruby/Workspace/shareyourstyle)  
> rake aborted!  
> You have a nil object when you didn’t expect it!  
> You might have expected an instance of Array.  
> The error occurred while evaluating nil.+

If I disable the line in environment.rb, everything is back to normal…

Any idea what is going on? Those errors message are really not doing  
much for me ☹

Thanks for your help!

Guillaume

---

<div class="post-metadata">

**Author:** ![djtal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@djtal](https://www.ruby-forum.com/u/djtal)\
**Post date:** [February 21, 2010, 2:53pm UTC](https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835/2 "2010-02-21T14:53:23Z")

</div>

On Feb 21, 1:09 pm, Guillaume G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “2540”  
> =\> Booting Mongrel  
> =\> Rails 2.3.5 application starting onhttp://127.0.0.1:3000  
> F:/Programming/Ruby/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/act ion\_controller/middleware\_stack.rb:98:in  
> `insert\_after’: You have a nil object when you didn’t expect it!  
> (NoMethodError)  
> You might have expected an instance of Array.  
> The error occurred while evaluating nil.+

Are you doing any other fiddling with the middleware stack ?

Fred

---

<div class="post-metadata">

**Author:** ![djtal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@djtal](https://www.ruby-forum.com/u/djtal)\
**Post date:** [February 21, 2010, 3:02pm UTC](https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835/3 "2010-02-21T15:02:35Z")

</div>

> > 
> 
> Are you doing any other fiddling with the middleware stack ?
> 
> Fred

Fred,

I personally don’t 🙂

Now, one of the plugin I use may… I removed the active\_store line from  
environment.rb (otherwise I can’t run anything) and ran “rake  
middleware”:

> rake middleware  
> (in F:/Programming/Ruby/Workspace/shareyourstyle)  
> use Rack::Lock  
> use ActionController::Failsafe  
> use ActionController::Session::CookieStore, #Proc:0x04d38098@:8(eval)  
> use Rack::Facebook, “523d1154a982433afddb3f5f77c0d17c”  
> use ActionController::ParamsParser  
> use Rack::MethodOverride  
> use Rack::Head  
> use ActionController::StringCoercion  
> use ActiveRecord::ConnectionAdapters::ConnectionManagement  
> use ActiveRecord::QueryCache  
> run ActionController::Dispatcher.new

I can see Facebook (Facebooker plugin) here, and CookieStore … The  
rest is the default, I guess?

Guillaume

---

<div class="post-metadata">

**Author:** ![djtal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@djtal](https://www.ruby-forum.com/u/djtal)\
**Post date:** [February 21, 2010, 3:10pm UTC](https://www.ruby-forum.com/t/activating-active-record-store-session-kills-the-app/183835/4 "2010-02-21T15:10:07Z")

</div>

Hey!

I made it work by going into initializers / session\_store.rb and  
activating the :active\_record\_store from there, using the line that was  
already there and commented (duh) :

ActionController::Base.session\_store = :active\_record\_store

Which is different from the one line I added to environment.rb:

config.action\_controller.session\_store = :active\_record\_store

So either the problem was :

1. the order in which files are loaded?
2. the line I used was only valid for previous versions of rails?

Any idea? Would love to have a better understanding of what I just did  
😉
