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 に答える