diff options
Diffstat (limited to 'railties/lib/rails_generator/generators/components/model')
-rw-r--r-- | railties/lib/rails_generator/generators/components/model/model_generator.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/model/templates/migration.rb | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/railties/lib/rails_generator/generators/components/model/model_generator.rb b/railties/lib/rails_generator/generators/components/model/model_generator.rb index dc33786b72..9be9cad8bf 100644 --- a/railties/lib/rails_generator/generators/components/model/model_generator.rb +++ b/railties/lib/rails_generator/generators/components/model/model_generator.rb @@ -1,5 +1,5 @@ class ModelGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false, :skip_fixture => false + default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false def manifest record do |m| @@ -35,6 +35,8 @@ class ModelGenerator < Rails::Generator::NamedBase def add_options!(opt) opt.separator '' opt.separator 'Options:' + opt.on("--skip-timestamps", + "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } opt.on("--skip-migration", "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } opt.on("--skip-fixture", diff --git a/railties/lib/rails_generator/generators/components/model/templates/migration.rb b/railties/lib/rails_generator/generators/components/model/templates/migration.rb index 387e9b141e..382fd1156e 100644 --- a/railties/lib/rails_generator/generators/components/model/templates/migration.rb +++ b/railties/lib/rails_generator/generators/components/model/templates/migration.rb @@ -3,8 +3,10 @@ class <%= migration_name %> < ActiveRecord::Migration create_table :<%= table_name %> do |t| <% for attribute in attributes -%> t.<%= attribute.type %> :<%= attribute.name %> -<% end %> +<% end -%> +<% unless options[:skip_timestamps] %> t.timestamps +<% end -%> end end |