开发者

before_filter checking multiple roles

In application_controller I have th开发者_开发百科e following method:

  def authorized_for_roles(*roles)
    roles.each{|role_name| return true if current_user.has_role?(role_name)}
    false
  end

In one of my controllers, I have

private

  def authorize_administration
    authorized_for_roles :administrator
  end

I am calling authorize_administration in my before_filter. Currently getting 'undefined method roles" error. Can someone tell me where I've gone wrong? the current_user is valid/defined, and the role can be checked.

Thanks


Is the error really in the authorized_for_roles def, or perhaps in the User model? Did you define has_many :roles for User?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜