Skip to content

Commit

Permalink
Added --skip-fixture option to script/generate model (closes #6862) […
Browse files Browse the repository at this point in the history
…sandofsky]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7601 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Sep 23, 2007
1 parent 6580b3a commit 906c49d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions railties/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Added --skip-fixture option to script/generate model #6862 [sandofsky]

* Print Rails version when starting console #7440 [eyematz] * 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] * Fixed the placement of fixture files for nested models when generating through script/generate model #7547 [jkit]
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
class ModelGenerator < Rails::Generator::NamedBase class ModelGenerator < Rails::Generator::NamedBase
default_options :skip_migration => false default_options :skip_migration => false, :skip_fixture => false


def manifest def manifest
record do |m| record do |m|
Expand All @@ -14,7 +14,10 @@ def manifest
# Model class, unit test, and fixtures. # Model class, unit test, and fixtures.
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") 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 '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] unless options[:skip_migration]
m.migration_template 'migration.rb', 'db/migrate', :assigns => { m.migration_template 'migration.rb', 'db/migrate', :assigns => {
Expand All @@ -34,5 +37,7 @@ def add_options!(opt)
opt.separator 'Options:' opt.separator 'Options:'
opt.on("--skip-migration", opt.on("--skip-migration",
"Don't generate a migration file for this model") { |v| options[:skip_migration] = v } "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
end end

0 comments on commit 906c49d

Please sign in to comment.