diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-06-23 18:26:58 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-06-23 18:26:58 +0000 |
commit | c4075292fac0032c0df73c724e13298817f77e52 (patch) | |
tree | 296494a1f11c6dca1f6db9848ce8d59d9dac8522 /railties/lib | |
parent | 1a0cdf74be951f9e732cfb8e6e1cd8a087c8ebdf (diff) | |
download | rails-c4075292fac0032c0df73c724e13298817f77e52.tar.gz rails-c4075292fac0032c0df73c724e13298817f77e52.tar.bz2 rails-c4075292fac0032c0df73c724e13298817f77e52.zip |
Added --skip-migration option to scaffold and resource generators (closes #8656) [Michael Glaesemann]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7108 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails_generator/generators/components/resource/resource_generator.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb | 13 |
2 files changed, 21 insertions, 3 deletions
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 5d9eefb5b2..cb0952dab8 100644 --- a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +++ b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb @@ -1,4 +1,6 @@ class ResourceGenerator < Rails::Generator::NamedBase + default_options :skip_migration => false + attr_reader :controller_name, :controller_class_path, :controller_file_path, @@ -57,7 +59,14 @@ class ResourceGenerator < Rails::Generator::NamedBase "Usage: #{$0} resource ModelName [field:type, field:type]" end - def model_name + def add_options!(opt) + opt.separator '' + opt.separator 'Options:' + opt.on("--skip-migration", + "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } + end + + def model_name class_name.demodulize end 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 11c80d2020..b26300e024 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb @@ -1,4 +1,6 @@ class ScaffoldGenerator < Rails::Generator::NamedBase + default_options :skip_migration => false + attr_reader :controller_name, :controller_class_path, :controller_file_path, @@ -51,7 +53,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) m.template('style.css', 'public/stylesheets/scaffold.css') - m.dependency 'model', [singular_name] + @args, :collision => :skip + m.dependency 'model', [singular_name] + @args, :collision => :skip m.template( 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") @@ -70,11 +72,18 @@ class ScaffoldGenerator < Rails::Generator::NamedBase "Usage: #{$0} scaffold ModelName [field:type, field:type]" end + def add_options!(opt) + opt.separator '' + opt.separator 'Options:' + opt.on("--skip-migration", + "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } + end + def scaffold_views %w[ index show new edit ] end - def model_name + def model_name class_name.demodulize end end |