Q:

Adding a key to the permitted params

I have this:
  def some_params
    params.require(:person).permit(:name, :pass)

These params are under the key "person" in "params". How can I add a key from the top level of "params" to the list of permitted params? In total it should result into 3 keys of permitted params.

A:

Just add other call to the method require like:
params = ActionController::Parameters.new({
  key1: 1,
  person: {
    name: 'Francesco',
    pass: 'pass'
  }
})
params.permit(:key1, {:person => [:name,  :pass]})

Check the docs at: https://github.com/rails/strong_parameters#require-multiple-parameters

Require Multiple Parameters
If you want to make sure that multiple keys are present in a params
  hash, you can call the method twice:
params.require(:token)
params.require(:post).permit(:title)

