Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Honor ActiveRecord::Base.pluralize_table_names when creating and dest…

…roying session store table. Closes #3204.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3317 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 56234bee14ad5219d4d1720a6a3532f684ed3a0d 1 parent 39766a9
Marcel Molina authored
Showing with 9 additions and 3 deletions.
  1. +2 −0  railties/CHANGELOG
  2. +7 −3 railties/lib/tasks/databases.rake
2  railties/CHANGELOG
View
@@ -1,5 +1,7 @@
*SVN*
+* Honor ActiveRecord::Base.pluralize_table_names when creating and destroying session store table. #3204. [rails@bencurtis.com, Marcel Molina Jr.]
+
* Update to script.aculo.us 1.5.0 final (equals 1.5.0_rc6) [Thomas Fuchs]
* Update to Prototype 1.4.0 final [Sam Stephenson]
10 railties/lib/tasks/databases.rake
View
@@ -128,6 +128,10 @@ def prepare_test_database_task
:ruby => :clone_schema_to_test}[ActiveRecord::Base.schema_format]
end
+def session_table_name
+ ActiveRecord::Base.pluralize_table_names ? :sessions : :session
+end
+
desc 'Prepare the test database and load the schema'
task :prepare_test_database => :environment do
Rake::Task[prepare_test_database_task].invoke
@@ -137,20 +141,20 @@ desc "Creates a sessions table for use with CGI::Session::ActiveRecordStore"
task :create_sessions_table => :environment do
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
- ActiveRecord::Base.connection.create_table :sessions do |t|
+ ActiveRecord::Base.connection.create_table session_table_name do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
- ActiveRecord::Base.connection.add_index :sessions, :session_id
+ ActiveRecord::Base.connection.add_index session_table_name, :session_id
end
desc "Drop the sessions table"
task :drop_sessions_table => :environment do
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
- ActiveRecord::Base.connection.drop_table :sessions
+ ActiveRecord::Base.connection.drop_table session_table_name
end
desc "Drop and recreate the session table (much faster than 'DELETE * FROM sessions')"
Please sign in to comment.
Something went wrong with that request. Please try again.