problem with rake db:sessions:clear and session_table_name

The comments in:


document this method for changing the session table_name:

   # You may configure the table name, primary key, and data column.
   # For example, at the end of config/environment.rb:
   # CGI::Session::ActiveRecordStore::Session.table_name = 'legacy_session_table'
   # CGI::Session::ActiveRecordStore::Session.primary_key = 'session_id'
   # CGI::Session::ActiveRecordStore::Session.data_column_name = 'legacy_session_data'

I am using this method to set a custom table name in the database for my sessions table.

This works fine however there's a problem with the following rake tasks:

   rake db:sessions:clear
   rake db:sessions:create

in file: railties/lib/tasks/databases.rb

They instead use the state of ActiveRecord::Base.pluralize_table_names to set the table mane to either 'session' or 'sessions'.

I started working on a patch but got confused figuring out where table_name is defined in activerecord_store.rb.

It's defined once as a cattr in this Class:


and again somehow in this class:


Any suggestions on how the patch should be constructed?