Module: ActionArgs::AbstractControllerClassMethods

Defined in:
lib/action_args/abstract_controller.rb

Instance Method Summary collapse

Instance Method Details

#permits(*attributes, model_name: nil, **kw_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


31
32
33
# File 'lib/action_args/abstract_controller.rb', line 31

def permits(*attributes, model_name: nil, **kw_attributes)
  @permitted_attributes, @permitting_model_name = attributes << kw_attributes, model_name
end