diff options
Diffstat (limited to 'railties/lib/generators/rails/resource')
-rw-r--r-- | railties/lib/generators/rails/resource/resource_generator.rb | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/railties/lib/generators/rails/resource/resource_generator.rb b/railties/lib/generators/rails/resource/resource_generator.rb index f61e55a01e..8d787aaa75 100644 --- a/railties/lib/generators/rails/resource/resource_generator.rb +++ b/railties/lib/generators/rails/resource/resource_generator.rb @@ -3,7 +3,9 @@ require 'generators/rails/model/model_generator' module Rails module Generators class ResourceGenerator < ModelGenerator - hook_for :resource_controller + hook_for :resource_controller do |base, controller| + base.invoke controller, [ base.name.pluralize, base.options[:actions] ] + end class_option :actions, :type => :array, :default => [], :banner => "ACTION ACTION", :desc => "Actions for the resource controller", :aliases => "-a" @@ -11,25 +13,8 @@ module Rails class_option :singleton, :type => :boolean, :default => false, :aliases => "-i", :desc => "Supply to create a singleton controller" - def invoke_for_resource_controller - return unless options[:resource_controller] - - klass = Rails::Generators.find_by_namespace(options[:resource_controller], :rails, :controller) - - if klass - args = [] - args << pluralize?(class_name) - args << options[:actions] - - say_status :invoke, options[:resource_controller], :blue - klass.new(args, options.dup, _overrides_config).invoke(:all) - else - say "Could not find and invoke '#{options[:resource_controller]}'." - end - end - def add_resource_route - route "map.resource#{"s" unless options[:singleton]} :#{pluralize?(file_name)}" + route "map.resource#{:s unless options[:singleton]} :#{pluralize?(file_name)}" end protected |