Module: Rails::Generators::ResourceHelpers
- Included in:
- Erb::Generators::ScaffoldGenerator, ResourceGenerator, ScaffoldControllerGenerator, TestUnit::Generators::ScaffoldGenerator
- Defined in:
- lib/rails/generators/resource_helpers.rb
Overview
Deal with controller names on scaffold and add some helpers to deal with ActiveModel.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
Set controller variables on initialization.
Class Method Details
.included(base) ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/rails/generators/resource_helpers.rb', line 11 def self.included(base) #:nodoc: base.class_option :force_plural, :type => :boolean, :desc => "Forces the use of a plural ModelName" end |
Instance Method Details
#initialize(*args) ⇒ Object
Set controller variables on initialization.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails/generators/resource_helpers.rb', line 17 def initialize(*args) #:nodoc: super if name == name.pluralize && ![:force_plural] unless ResourceHelpers.skip_warn say "Plural version of the model detected, using singularized version. Override with --force-plural." ResourceHelpers.skip_warn = true end name.replace name.singularize assign_names!(name) end @controller_name = name.pluralize end |