Module: ActionController::ModifyResource::ClassMethods

Defined in:
lib/modify_resource/rails/action_controller/modify_resource.rb

Instance Method Summary collapse

Instance Method Details

#modify_on(*actions) ⇒ Object

A shortcut - just add modify_on :create, :update if your variable is the controller’s name – e.g. @widget in WidgetsController



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/modify_resource/rails/action_controller/modify_resource.rb', line 14

def modify_on(*actions)
  # Define in the method so that the user could override if they wanted
  options = actions.extract_options!
  actions.each do |action|
    unless method_defined?(action)
      define_method action do
        modify_resource_with action, options
      end
    end
  end
end