diff options
author | José Valim <jose.valim@gmail.com> | 2009-08-30 17:58:20 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-08-30 17:58:20 +0200 |
commit | 0efedf2a30a12cdaa261556e3684c630690afe0f (patch) | |
tree | 0f646b621abc18caa6b00c1890bd825dd0236100 /railties/lib/generators/rails/resource | |
parent | 5096ba961c49e5b419c3400acd7c87373a36d6d4 (diff) | |
download | rails-0efedf2a30a12cdaa261556e3684c630690afe0f.tar.gz rails-0efedf2a30a12cdaa261556e3684c630690afe0f.tar.bz2 rails-0efedf2a30a12cdaa261556e3684c630690afe0f.zip |
Ensure scaffold works properly even if plural name is given. [#3062]
Diffstat (limited to 'railties/lib/generators/rails/resource')
-rw-r--r-- | railties/lib/generators/rails/resource/resource_generator.rb | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/railties/lib/generators/rails/resource/resource_generator.rb b/railties/lib/generators/rails/resource/resource_generator.rb index 70babc0550..9abb8bbeaf 100644 --- a/railties/lib/generators/rails/resource/resource_generator.rb +++ b/railties/lib/generators/rails/resource/resource_generator.rb @@ -1,25 +1,19 @@ require 'generators/rails/model/model_generator' +require 'generators/resource_helpers' module Rails module Generators class ResourceGenerator < ModelGenerator #metagenerator + include ResourceHelpers + hook_for :resource_controller, :required => true do |base, controller| - base.invoke controller, [ base.name.pluralize, base.options[:actions] ] + base.invoke controller, [ base.controller_name, base.options[:actions] ] end class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [], :desc => "Actions for the resource controller" - class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" - class_option :force_plural, :type => :boolean, :desc => "Forces the use of a plural ModelName" - - def initialize(*args) - super - if name == name.pluralize && !options[:force_plural] - say "Plural version of the model detected, using singularized version. Override with --force-plural." - name.replace name.singularize - end - end + class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" def add_resource_route route "map.resource#{:s unless options[:singleton]} :#{pluralize?(file_name)}" |