1

I can't create an object with a user_id with active admin because user_id is protected. If I leave user_id out of attr_accessible then the object is not secure.

LightBox
  • 3,395
  • 4
  • 25
  • 38
  • 1
    http://stackoverflow.com/questions/8796827/using-rails-3-1-as-admin-for-updating-attributes-protected-by-attr-accessib – Zippie Mar 20 '13 at 13:10
  • 1
    Link is interesting but does not solve the problem. It would if I was rolling my own admin interface. It does not look like active admin uses the ":as => :admin" feature. – LightBox Mar 20 '13 at 15:43

1 Answers1

1

ActiveAdmin use InheritedResource, so you can use with_role class method for each controller,

Check https://github.com/josevalim/inherited_resources/issues/151

To setup all by default try

# config/initializers/active_admin.rb
module ActiveAdmin
  class BaseController
    with_role :admin
  end
end

BTW good article about this problem http://ejholmes.github.com/2012/04/22/handling-mass-assignment-with-active-admin.html

Fivell
  • 11,829
  • 3
  • 61
  • 99