Class: AbstractController::Base
- Inherits:
-
Object
- Object
- AbstractController::Base
- Defined in:
- lib/action_args/abstract_controller.rb
Class Method Summary collapse
-
.permits(*attributes) ⇒ Object
You can configure StrongParameters’ ‘permit` attributes using this DSL method.
Instance Method Summary collapse
-
#send_action(method_name, *args) ⇒ Object
no StrongParameters.
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 31 32 |
# File 'lib/action_args/abstract_controller.rb', line 26 def self.permits(*attributes) if attributes.last.is_a?(Hash) && attributes.last. && attributes.last.has_key?(:model_name) = attributes.pop @permitting_model_name = [:model_name] end @permitted_attributes = attributes end |
Instance Method Details
#send_action(method_name, *args) ⇒ Object
no StrongParameters
35 36 37 38 39 40 41 42 43 |
# File 'lib/action_args/abstract_controller.rb', line 35 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 |