Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ActiveAdmin to work with Strong Parameters?

Update: this question was asked before there was a solution for it already in ActiveAdmin. As Joseph states, the ActiveAdmin documentation now contains this information, but the answers here are provided for those working with older versions of ActiveAdmin.

When the strong_parameters 0.1.4 is used with ActiveAdmin 0.5.0 in Rails 3.2.8, if the model you are using is using StrongParameters by including:

include ::ActiveModel::ForbiddenAttributesProtection 

then you get the following error in the log if you try to create/edit a record:

ActiveModel::ForbiddenAttributes (ActiveModel::ForbiddenAttributes) 
like image 373
Gary S. Weaver Avatar asked Oct 26 '12 16:10

Gary S. Weaver


2 Answers

Update to the latest inherited_resources gem and do this in your controller block:

ActiveAdmin.register Blog do   #...   controller do     #...     def permitted_params       params.permit(:blog => [:name, :description])       # params.permit! # allow all parameters     end   end end 
like image 139
Brendon Muir Avatar answered Oct 14 '22 08:10

Brendon Muir


The documentation now clearly states how to go about Setting up Strong Parameters in Rails 4. See:

https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters

like image 43
Joseph N. Avatar answered Oct 14 '22 08:10

Joseph N.