Action Controller Parameters

Allows you to choose which attributes should be permitted for mass updating and thus prevent accidentally exposing that which shouldn’t be exposed. Provides two methods for this purpose: require and permit . The former is used to mark parameters as required. The latter is used to set the parameter as permitted and limit which attributes should be allowed for mass updating.

params = ActionController::Parameters.new( < person: < name: "Francesco", age: 22, role: "admin" >>) permitted = params.require(:person).permit(:name, :age) permitted # => #"Francesco", "age"=>22> permitted: true> permitted.permitted? # => true Person.first.update!(permitted) # => #

It provides two options that controls the top-level behavior of new instances: