2

In my models I have defined different roles for mass assignment. Some fields are attr_accessible :as => :default. Other fields are attr_accessible :as => [:default, :admin].

How can I allow ActiveAdmin to be able to update attributes as an admin role?

ProgramFOX
  • 6,131
  • 11
  • 45
  • 51
Venkat D.
  • 2,979
  • 35
  • 42

2 Answers2

6

You can use the with_role options for ActiveAdmin controllers. For example:

# app/admin/users.rb
ActiveAdmin.register User do
  controller { with_role :admin }
end
Venkat D.
  • 2,979
  • 35
  • 42
2

As Venkat said in the other answer you can do that with the with_role option. But it's a better idea IMHO to insert it in config/initializers/active_admin.rb instead of in every controller:

module ActiveAdmin
  ResourceController.class_eval do
    with_role :admin
  end
end
Community
  • 1
  • 1
KARASZI István
  • 30,900
  • 8
  • 101
  • 128