Activeadmin Forbiddenattributeserror

ActiveAdmin ForbiddenAttributesError

Rails 4 uses strong parameters, which moves attribute whitelisting from the model to the controller. It is necessary to specify the attributes that you would like to be saved in the database. You have not permitted the attributes in your code, which is why you are receiving the ActiveModel::ForbiddenAttributesError.

Refer to the documentation of ActiveAdmin : Setting up Strong Parameters

You can setup strong parameters in the following way, using permit_params method which creates a method called permitted_params, use this method when overriding create or update actions:

ActiveAdmin.register AdminUser do
## ...
permit_params :attr1, :attr2 ## Add this line

Replace :attr1, :attr2, etc with the actual attribute names that you want to whitelist. For example: :email

ForbiddenAttributesError with Active Admin

I think you didn't add permit_params in your active admin file.

# app/admin/xyz.rb
permit_params :comma separated attributes.

Look into this link for more detail.

Rails 4 and Active Admin: ActiveModel::ForbiddenAttributesError

Alright figured it out. I'm not sure if this is the 'correct' way but the products are being created.

in app/admin/product.rb I did:

permit_params :list, :of, :attributes, :on, :model, :name, :price


permit_params :list, :of, :attributes, :on, :model

was initially commented out. So I just added :name and :price

ActiveModel::ForbiddenAttributesError showing even when I've added all of the attributes to the strong parameters

I had a typo on the permit_params declaration. I just removed the equal sign.


permit_params = :prefix, :firstname, :lastname, :password, :email, :membership_code, :birthdate, :contact_number, :location, :active, :confirmed, :remember_token, :town, :province


permit_params :prefix, :firstname, :lastname, :password, :email, :membership_code, :birthdate, :contact_number, :location, :active, :confirmed, :remember_token, :town, :province

Thanks! @nistvan

ActiveModel::ForbiddenAttributesError within Active Admin

I was missing

  controller do
def permitted_params
params.permit event: [:venue, :trainer_id, :description, :training_request_id, :title, :date]

inside ActiveAdmin.register Event do

Can't update resource from ActiveAdmin interface -- ActiveModel::ForbiddenAttributesError

Solved it by adding this to admin/thing.rb

controller do
def permitted_params
params.permit thing: [ :title, :description, :image_file_name, :image_content_type, :image_file_size, ":image_updated_at(1i)", ":image_updated_at(2i)", ":image_updated_at(3i)", ":image_updated_at(4i)", ":image_updated_at(5i)" ]

Related Topics

Leave a reply