I am using Devise, when submitting the data from the form (user registration), I inspect the parameters in the controller with
render plain: params.inspect
and I get the following as a result:
<ActionController::Parameters {"utf8"=>"✓", "authenticity_token"=>"H2rNXQCfedwIKrKNtaNQlTGU+EyENNKvR57qYz5qzpggiu4xd3TE4QCdEsPYcq97mEe0FLcBHwhNQQvT15hlzw==", "user"=>{"nombre"=>"test5", "apellido"=>"", "cargo"=>"", "telefono"=>"", "email"=>"[email protected]", "direccion"=>"", "contrato"=>"123", "compania"=>"", "password"=>"123123", "password_confirmation"=>"123123", "user_type"=>"Cliente"}, "commit"=>"Guardar", "controller"=>"registrations", "action"=>"create"} permitted: false>
Now if I want to access the contract, doing the following
render plain: params[:contrato].inspect
I get a beautiful:
nil
Does anyone know what the heck is going on here?
In your parameter information:
contrato
is nested insideuser
, so the correct way to access it would be withparams[:user][:contrato]
.