2
votes

We are upgrading Rails 3.2 engine to Rails 4.2.0 on ruby 2.0.0. Gem 'activerecord-session_store' was added to engine's gemspec following gem's instruction:

 s.add_dependency 'activerecord-session_store' 

and added following in initializers/session_store.rb under dummy:

Dummy::Application.config.session_store :active_record_store, :key => '_my_app_session'

then, we did bundle install. When we ran:

bundle exec rails generate active_record:session_migration

There is the error from the gem's generator:

/activerecord-session_store-0.1.1/lib/generators/active_record/session_migration_generator.rb:16:in `session_table_name': uninitialized co
nstant ActiveRecord::SessionStore (NameError).

We move the gem into engine's Gemfile and same error. Why the SessionStore is still not initialized?

Update

In engine's engine.rb under lib, the session table is pointed to:

initializer "Authentify.add_middleware" do |app|
  ActiveRecord::SessionStore::Session.table_name = 'authentify_sessions'
  app.middleware.use ActiveRecord::SessionStore
end 

The setup works for Rails 3.2.

2
Since this is a upgrading from 3.2 to 4.2, the session table has been created already. I am wondering if rails g migration activerecord:session_migration needs to be ran at all. - user938363

2 Answers

2
votes

If you were not using the default table name for sessions, set:

ActiveRecord::SessionStore::Session.table_name = 'your_old_session_table'

in config/application.rb.

Additional configuration.

1
votes

What we did is to add gem 'activerecord-session_store' to engine's Gemfile in addition to the .gemspec. The error disappeared.