开发者

declarative_authorization Authorization.current_user error

开发者 https://www.devze.com 2023-04-02 01:29 出处:网络
I have authlogic set up and want to use declarative_authorization. In Ryan Bates\'s railcast #188 he uses

I have authlogic set up and want to use declarative_authorization. In Ryan Bates's railcast #188 he uses before_filter {|c| Authorization.current_user = c.current_user} If I do the same I get an开发者_如何学JAVA error:

`private method 'current_user' called for #<UsersController:0xa6025e8>`

The current_user method is in application controller and is private (as in the Authlogic setup example) and if I make it public, this works. It also works if I just say current_user (current_user method is also a helper) instead of c.current_user in the before filter block.

So would it actually be ok if I would just do before_filter {Authorization.current_user = current_user}?


Try this:

application_controller.rb

Add before_filter :set_current_user

Put this method into protected

def set_current_user
  Authorization.current_user = current_user 
end
0

精彩评论

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