I'm on Rails 4 and using Active Admin. I need to have a different set of parameters permissible for the create
and update
methods, so I am approaching this by modifying the instructions from the Active Admin documentation. Here is what I am trying to do:
My model needs to take the following set of parameters on create:
:name, :region, :contact_details, :province_id, :status_id, :start_date
But is should not change :region
on update. So, without overriding the default Active Admin’s update method, I am modifying permit_params
as follows:
permit_params do
params = [:name, :contact_details, :province_id, :status_id, :start_date]
params.push(:region) unless params[:action] == "update"
params
end
The result is inevitably the following error:
TypeError: no implicit conversion of Symbol into Integer
which occurs, I believe, when permit_params
is creating the method permitted_params
.
What am I doing wrong? What is the solution?