diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-23 22:08:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-23 22:08:02 +0000 |
commit | 906c49d0f3fb183967e072abbf8007aa1acdab35 (patch) | |
tree | edde4344821e1d84a2bd7ee152a5245d7332387c | |
parent | 6580b3ab003e7140918eb7984d618e5d6c472b1a (diff) | |
download | rails-906c49d0f3fb183967e072abbf8007aa1acdab35.tar.gz rails-906c49d0f3fb183967e072abbf8007aa1acdab35.tar.bz2 rails-906c49d0f3fb183967e072abbf8007aa1acdab35.zip |
Added --skip-fixture option to script/generate model (closes #6862) [sandofsky]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7601 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/model/model_generator.rb | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index d3b35b5bca..974f3a2ef5 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added --skip-fixture option to script/generate model #6862 [sandofsky] + * Print Rails version when starting console #7440 [eyematz] * Fixed the placement of fixture files for nested models when generating through script/generate model #7547 [jkit] 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 2696a31656..fccf30211a 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 + default_options :skip_migration => false, :skip_fixture => false def manifest record do |m| @@ -14,7 +14,10 @@ class ModelGenerator < Rails::Generator::NamedBase # Model class, unit test, and fixtures. m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") - m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") + + unless options[:skip_fixture] + m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") + end unless options[:skip_migration] m.migration_template 'migration.rb', 'db/migrate', :assigns => { @@ -34,5 +37,7 @@ class ModelGenerator < Rails::Generator::NamedBase opt.separator 'Options:' opt.on("--skip-migration", "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } + opt.on("--skip-fixture", + "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v} end end |