How to get ActiveAdmin to work with Strong Parameters? How to get ActiveAdmin to work with Strong Parameters? ruby-on-rails ruby-on-rails

How to get ActiveAdmin to work with Strong Parameters?


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  endend


The accepted answer did not work for me with resources defined in an engine, so I tracked down the original resource_params in inherited_resources/lib/inherited_resources/base_helpers.rb and came up with this solution which closer mimics that code, and which works with engines:

In config/initializers/active_admin.rb:

ActiveAdmin::ResourceController.class_eval do  # Allow ActiveAdmin admins to freely mass-assign when using strong_parameters  def resource_params    [(params[resource_request_name] || params[resource_instance_name]).try(:permit!) || {}]  endend