diff options
Diffstat (limited to 'railties')
3 files changed, 20 insertions, 2 deletions
diff --git a/railties/lib/generators/active_record/session_migration/session_migration_generator.rb b/railties/lib/generators/active_record/session_migration/session_migration_generator.rb index d60da5c0a5..d78b9d42b0 100644 --- a/railties/lib/generators/active_record/session_migration/session_migration_generator.rb +++ b/railties/lib/generators/active_record/session_migration/session_migration_generator.rb @@ -12,7 +12,11 @@ module ActiveRecord protected def session_table_name - ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session' + current_table_name = ActiveRecord::SessionStore::Session.table_name + if current_table_name == "sessions" || current_table_name == "session" + current_table_name = (ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session') + end + current_table_name end end diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 23a3a73a7f..0fefc0433a 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -448,7 +448,7 @@ def drop_database(config) end def session_table_name - ActiveRecord::Base.pluralize_table_names ? :sessions : :session + ActiveRecord::SessionStore::Session.table_name end def set_firebird_env(config) diff --git a/railties/test/generators/session_migration_generator_test.rb b/railties/test/generators/session_migration_generator_test.rb index f83109800b..a87eeb1e1a 100644 --- a/railties/test/generators/session_migration_generator_test.rb +++ b/railties/test/generators/session_migration_generator_test.rb @@ -2,6 +2,16 @@ require 'abstract_unit' require 'generators/generators_test_helper' require 'generators/rails/session_migration/session_migration_generator' +module ActiveRecord + module SessionStore + class Session + class << self + attr_accessor :table_name + end + end + end +end + class SessionMigrationGeneratorTest < GeneratorsTestCase def test_session_migration_with_default_name @@ -14,6 +24,10 @@ class SessionMigrationGeneratorTest < GeneratorsTestCase assert_migration "db/migrate/create_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/ end + def test_session_migtions_with_custom_table_name + run_generator + assert_migration "db/migrate/add_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/ + end protected def run_generator(args=[]) |