Class: AbstractController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_args/abstract_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.permits(*attributes) ⇒ Object

You can configure StrongParameters' permit attributes using this DSL method. The permit call will be invoked only against parameters having the resource model name inferred from the controller class name.

class UsersController < ApplicationController
permits :name, :age

def create(user)
  @user = User.new(user)
end
end


26
27
28
29
30
# File 'lib/action_args/abstract_controller.rb', line 26

def self.permits(*attributes)
  options = attributes.extract_options!
  @permitting_model_name = options[:model_name] if options.has_key? :model_name
  @permitted_attributes = attributes
end

Instance Method Details

#send_action(method_name, *args) ⇒ Object

no StrongParameters



33
34
35
36
37
38
39
40
41
# File 'lib/action_args/abstract_controller.rb', line 33

def send_action(method_name, *args)
  return send method_name, *args unless args.empty?
  return send method_name, *args unless defined?(params)

  method_parameters = method(method_name).parameters
  ActionArgs::ParamsHandler.strengthen_params!(self.class, method_parameters, params)
  values = ActionArgs::ParamsHandler.extract_method_arguments_from_params method_parameters, params
  send method_name, *values
end