0

如果在我的应用程序中设置了会话变量,我想授权特定操作。我不知道该怎么做。就像是:

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

我不明白如何完成这个基本任务。任何帮助表示赞赏。

4

1 回答 1

0

您想在函数上使用 before_filter 例如

before_filter :authorize, :only => :action

private
def authorize
unless session[:key]
flash[:notice] = "Cannot do this"
redirect_to(:controller => "controller", :action => "otheraction")
end
于 2011-08-16T16:04:55.243 回答