开发者

How do I get rid of blank error page with "You are not allowed to access this action." in decl_auth in Rails 3?

开发者 https://www.devze.com 2023-02-12 07:10 出处:网络
The authorization works nicely, but when a user accesses an action/controller that they don\'t have access to, they see:

The authorization works nicely, but when a user accesses an action/controller that they don't have access to, they see:

You are not allowed to access this action

The page is blank.

How do I c开发者_高级运维ustomize what the user sees ? Either by replacing the message altogether, to replacing the page with a new page altogether ?

How would I do this ?

Thanks.


To handle this, I added a permission_denied method in the ApplicationController:

def permission_denied
  flash[:notice] = "Sorry, you are not authorized to access that page." 
  redirect_to root_url
end

See last section of this Railscast: http://asciicasts.com/episodes/188-declarative-authorization

0

精彩评论

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