Module: Rails::Generators::ResourceHelpers

Overview

Deal with controller names on scaffold and add some helpers to deal with ActiveModel.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:


10
11
12
13
# File 'lib/rails/generators/resource_helpers.rb', line 10

def self.included(base) #:nodoc:
  base.include(Rails::Generators::ModelHelpers)
  base.class_option :model_name, type: :string, desc: "ModelName to be used"
end

Instance Method Details

#initialize(*args) ⇒ Object

Set controller variables on initialization.


16
17
18
19
20
21
22
23
24
25
# File 'lib/rails/generators/resource_helpers.rb', line 16

def initialize(*args) #:nodoc:
  super
  controller_name = name
  if options[:model_name]
    self.name = options[:model_name]
    assign_names!(self.name)
  end

  assign_controller_names!(controller_name.pluralize)
end