I am upgrading an app from a very old ruby on rails to ruby 3.2.4 with rails 7.1.3.2. I am having trouble with using :active_record for the session store so I went back to basics and generated the blog app as described in a ruby tutorial. When I put in the initializer to use :active_record rails immediately gives an error.
I am running on ubuntu 22.04.
Here is my Gemfile with comments removed
source "https://rubygems.org"ruby "3.2.4"gem "rails", "~> 7.1.3", ">= 7.1.3.2"gem "sprockets-rails"gem "sqlite3", "~> 1.4"gem "puma", ">= 5.0"gem "importmap-rails"gem "turbo-rails"gem "stimulus-rails"gem "jbuilder"gem "tzinfo-data", platforms: %i[ windows jruby ]gem "bootsnap", require: falsegem 'activerecord-session_store', github: 'rails/activerecord-session_store'group :development, :test do gem "debug", platforms: %i[ mri windows ]endgroup :development do gem "web-console"endgroup :test do gem "capybara" gem "selenium-webdriver"end
Here is the initializer
Rails.application.config.session_store :active_record
When I run
bundle exec rails generate active_record:session_migration
I get the following stack trace
/home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/actionpack-7.1.3.2/lib/action_dispatch/middleware/stack.rb:42:in `build': undefined method `new' for ActiveRecord:Module (NoMethodError) klass.new(app, *args, &block) ^^^^ from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/actionpack-7.1.3.2/lib/action_dispatch/middleware/stack.rb:171:in `block in build' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/actionpack-7.1.3.2/lib/action_dispatch/middleware/stack.rb:167:in `each' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/actionpack-7.1.3.2/lib/action_dispatch/middleware/stack.rb:167:in `inject' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/actionpack-7.1.3.2/lib/action_dispatch/middleware/stack.rb:167:in `build' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/engine.rb:522:in `block in app' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/engine.rb:518:in `synchronize' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/engine.rb:518:in `app' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `instance_exec' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `run' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:61:in `block in run_initializers' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `each' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `call' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:60:in `run_initializers' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/application.rb:426:in `initialize!' from /mnt/hgfs/legalfirst/websites/dev/blog/config/environment.rb:5:in `<main>' from <internal:/home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from <internal:/home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:34:in `require' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/application.rb:402:in `require_environment!' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command/actions.rb:20:in `boot_application!' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/commands/generate/generate_command.rb:21:in `perform' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command/base.rb:178:in `invoke_command' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command/base.rb:73:in `perform' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command.rb:71:in `block in invoke' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command.rb:149:in `with_argv' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/command.rb:69:in `invoke' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/railties-7.1.3.2/lib/rails/commands.rb:18:in `<main>' from <internal:/home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from <internal:/home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from /home/sysadmin/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from bin/rails:4:in `<main>'
Can anyone tell me please how to configure Rails 7.1.3 to use :active_record for session storage. Refactoring my app not to use :active_record will take a lot of work.
Thanks in advance for your assistance.