diff options
4 files changed, 12 insertions, 4 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 diff --git a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb index cb0952dab8..669f4ff904 100644 --- a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +++ b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb @@ -1,5 +1,5 @@ class ResourceGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false + default_options :skip_timestamps => false, :skip_migration => false attr_reader :controller_name, :controller_class_path, @@ -62,6 +62,8 @@ class ResourceGenerator < 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 } end diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb index 6f154fe52d..d9ce668f2e 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb @@ -1,5 +1,5 @@ class ScaffoldGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false + default_options :skip_timestamps => false, :skip_migration => false attr_reader :controller_name, :controller_class_path, @@ -76,6 +76,8 @@ class ScaffoldGenerator < 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 } end |