开发者

has_permission_on with Declarative Authorization, non attribute condition

I want to give authorization to a开发者_JS百科 specific action if a session variable is set in my app. I can't figure out how to do this. Something like:

has_permission_on :admin, :to => :action do
  true if session[:key]
end

I don't understand how to accomplish this basic task. Any help appreciated.


You want to use a before_filter on the function e.g.

before_filter :authorize, :only => :action

private
def authorize
unless session[:key]
flash[:notice] = "Cannot do this"
redirect_to(:controller => "controller", :action => "otheraction")
end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜