1
votes

I want to save session to ActiveRecord instead of cookie. I'm proceeding with reference to this site
Active Record Session Store

gem 'activerecord-session_store'


bundle install

rails generate active_record:session_migration

then,
error

/vendor/bundle/ruby/2.7.0/gems/activerecord-session_store-1.1.3/lib/activerecord/session_store.rb:2:in `<main>': undefined method `config' for nil:NilClass (NoMethodError)

I got this error. I tried:

/config/initializers/session_store.rb(File created by myself)

AppName::Application.config.session_store :active_record_store, key: "_#{Rails.application.class.parent_name.downcase}_session"

After writing, again

rails generate active_record:session_migration

I did, but after all

/vendor/bundle/ruby/2.7.0/gems/activerecord-session_store-1.1.3/lib/activerecord/session_store.rb:2:in `<main>': undefined method `config' for nil:NilClass (NoMethodError)

environment
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin20]
Rails 6.1.0
sqlite3 3.32.3

1

1 Answers

0
votes

Your code example in config looks a bit outdated (for an older rails version).

Try Rails.application.config.session_store in place of AppName::Application.config.session_store