aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/generators/rails/resource
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-06-29 19:56:22 +0200
committerJosé Valim <jose.valim@gmail.com>2009-06-29 19:56:22 +0200
commit95ef9bd67fa5ae21ed38ae118255ee7408dedec1 (patch)
treee314425452ecec95383858bb2bc9ff9502ce8869 /railties/lib/generators/rails/resource
parentff4c6004484a3201f28f7512531c4e8f5f58b617 (diff)
downloadrails-95ef9bd67fa5ae21ed38ae118255ee7408dedec1.tar.gz
rails-95ef9bd67fa5ae21ed38ae118255ee7408dedec1.tar.bz2
rails-95ef9bd67fa5ae21ed38ae118255ee7408dedec1.zip
Simplifying resource generator.
Diffstat (limited to 'railties/lib/generators/rails/resource')
-rw-r--r--railties/lib/generators/rails/resource/resource_generator.rb23
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