Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed reference to AR::SessionStore::Session.table_name in session mi…

…grations

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit c0f828ca4f3aa45a4c8ea8761183ad3854f0a13f 1 parent 4d15528
@eladmeidar eladmeidar authored lifo committed
View
6 railties/lib/generators/active_record/session_migration/session_migration_generator.rb
@@ -12,7 +12,11 @@ def create_migration_file
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
View
2  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)
View
14 railties/test/generators/session_migration_generator_test.rb
@@ -2,6 +2,16 @@
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 @@ def test_session_migration_with_given_name
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=[])
Please sign in to comment.
Something went wrong with that request. Please try again.