aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-11-04 20:30:45 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-11-04 20:30:45 +0000
commitee1ad762a4eff7bd1c04abe2290311a4b93f5459 (patch)
treeaa75dccf0fb32911e53b53cadcded85b77a8af5f /railties
parent3953839e9958588aaa659213b6445f9ea6a55e0f (diff)
downloadrails-ee1ad762a4eff7bd1c04abe2290311a4b93f5459.tar.gz
rails-ee1ad762a4eff7bd1c04abe2290311a4b93f5459.tar.bz2
rails-ee1ad762a4eff7bd1c04abe2290311a4b93f5459.zip
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
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails_generator/generators/components/model/model_generator.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/migration.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/resource/resource_generator.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb4
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