diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-05-22 21:09:47 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-05-22 21:09:47 +0000 |
commit | 3de8239a7c93aed5883aaa00e36086b0c3e1572f (patch) | |
tree | 0ae9feadbfd5212b93b00296f6545d7447ddf661 /railties/lib/rails_generator/generators/components | |
parent | f91096a543895a49876ec8e276cefefff6fdbe5a (diff) | |
download | rails-3de8239a7c93aed5883aaa00e36086b0c3e1572f.tar.gz rails-3de8239a7c93aed5883aaa00e36086b0c3e1572f.tar.bz2 rails-3de8239a7c93aed5883aaa00e36086b0c3e1572f.zip |
Session migration generator obeys pluralize_table_names. Closes #5145.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4360 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails_generator/generators/components')
2 files changed, 10 insertions, 4 deletions
diff --git a/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb b/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb index a513fa5cbf..2e177033a1 100644 --- a/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +++ b/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb @@ -6,7 +6,13 @@ class SessionMigrationGenerator < Rails::Generator::NamedBase def manifest record do |m| - m.migration_template 'migration.rb', 'db/migrate' + m.migration_template 'migration.rb', 'db/migrate', + :assigns => { :session_table_name => default_session_table_name } end end + + protected + def default_session_table_name + ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session' + end end diff --git a/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb b/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb index 0ab7fcb1e9..c76bd8dde4 100644 --- a/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +++ b/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb @@ -1,15 +1,15 @@ class <%= class_name %> < ActiveRecord::Migration def self.up - create_table :sessions do |t| + create_table :<%= session_table_name %> do |t| t.column :session_id, :string t.column :data, :text t.column :updated_at, :datetime end - add_index :sessions, :session_id + add_index :<%= session_table_name %>, :session_id end def self.down - drop_table :sessions + drop_table :<%= session_table_name %> end end |