Search code examples
ruby-on-railsactiveadmincrudmass-assignment

Mass-assigning attributes in ActiveAdmin


I try to create new user using Active Admin and I get:

Can't mass-assign protected attributes: user_id, approved_at_date, approved_at_time_hour, approved_at_time_minute, expire_at_date, expire_at_time_hour, expire_at_time_minute

And yes, these attributes aren't accessible for usual user. But I would like them to be accessible in admin panel. How to achieve this?


Solution

  • There is a with_role method of inherited_resources that is used by active admin to assign a scope to certain attributes such that they are only accessible to active admin but not to general users.

    Check out the Scoped Mass Assignment with Active Admin.