diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-04-17 19:17:02 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-04-18 17:59:03 -0300 |
commit | 39861395ffeaed6a164da5011f427f4184626b49 (patch) | |
tree | 40d3df5275c2d1ddfdcf7159540968ce5f23b29a /railties/lib/rails | |
parent | 476fa7aca2f64604ff164700d679511d369227b9 (diff) | |
download | rails-39861395ffeaed6a164da5011f427f4184626b49.tar.gz rails-39861395ffeaed6a164da5011f427f4184626b49.tar.bz2 rails-39861395ffeaed6a164da5011f427f4184626b49.zip |
Add hook for add_resource_route
Diffstat (limited to 'railties/lib/rails')
3 files changed, 16 insertions, 7 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 27f8d13ce8..c1967093ac 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -57,6 +57,7 @@ module Rails :orm => false, :performance_tool => nil, :resource_controller => :controller, + :resource_route => true, :scaffold_controller => :scaffold_controller, :stylesheets => true, :stylesheet_engine => :css, @@ -182,6 +183,7 @@ module Rails [ "rails", + "resource_route", "#{orm}:migration", "#{orm}:model", "#{orm}:observer", diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb index c7345f3cfb..3a0586ee43 100644 --- a/railties/lib/rails/generators/rails/resource/resource_generator.rb +++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb @@ -14,13 +14,7 @@ module Rails class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [], :desc => "Actions for the resource controller" - def add_resource_route - return if options[:actions].present? - route_config = regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ") - route_config << "resources :#{file_name.pluralize}" - route_config << " end" * regular_class_path.size - route route_config - end + hook_for :resource_route, :required => true end end end diff --git a/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb b/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb new file mode 100644 index 0000000000..6a5d62803c --- /dev/null +++ b/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb @@ -0,0 +1,13 @@ +module Rails + module Generators + class ResourceRouteGenerator < NamedBase + def add_resource_route + return if options[:actions].present? + route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ") + route_config << "resources :#{file_name.pluralize}" + route_config << " end" * regular_class_path.size + route route_config + end + end + end +end |