Ruby on rails 获取修改记录的用户类型-Rails

Ruby on rails 获取修改记录的用户类型-Rails,ruby-on-rails,activeadmin,attr-accessible,Ruby On Rails,Activeadmin,Attr Accessible,我的模型中有: attr_accessible :name, as: :admin 在我的活动管理员初始值设定项中: module ActiveAdmin class BaseController with_role :admin end end 是否可以让正在模型中编辑记录的角色执行以下操作: validate :thing, if: ->{ modifier == :admin } validate :something def something if m

我的模型中有:

attr_accessible :name, as: :admin
在我的活动管理员初始值设定项中:

module ActiveAdmin
  class BaseController
    with_role :admin
  end
end
是否可以让正在模型中编辑记录的角色执行以下操作:

validate :thing, if: ->{ modifier == :admin }
validate :something

def something
  if modifier == 'admin'
     # some code here

我现在使用了一个
attr\u访问器

class Service
  attr_accessor :modifier
  attr_accessible ..., :modifier, as: :admin
我通过以下表格发送:

ActiveAdmin.register Service do
  form do |f|
    f.input :modifier, as: :hidden, input_html: { value: :admin }
    ...
然后我可以这样使用它:

validate :thing, if: ->{ modifier == :admin }
validate :something

def something
  if modifier == 'admin'
     # some code here