diff options
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 |