Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added --skip-timestamps to generators that produce models (closes #10036

) [tpope]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8070 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ee1ad762a4eff7bd1c04abe2290311a4b93f5459 1 parent 3953839
@dhh dhh authored
View
4 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 @@ def banner
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",
View
4 railties/lib/rails_generator/generators/components/model/templates/migration.rb
@@ -3,8 +3,10 @@ def self.up
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
View
4 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 @@ def banner
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
View
4 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 @@ def banner
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
Please sign in to comment.
Something went wrong with that request. Please try again.