授权运行良好,但是当用户访问他们无权访问的操作/控制器时,他们会看到:
You are not allowed to access this action
页面是空白的。
如何自定义用户看到的内容?要么完全替换消息,要么完全用新页面替换页面?
我该怎么做?
谢谢。
授权运行良好,但是当用户访问他们无权访问的操作/控制器时,他们会看到:
You are not allowed to access this action
页面是空白的。
如何自定义用户看到的内容?要么完全替换消息,要么完全用新页面替换页面?
我该怎么做?
谢谢。
为了解决这个问题,我在ApplicationController中添加了一个permission_denied方法:
def permission_denied
flash[:notice] = "Sorry, you are not authorized to access that page."
redirect_to root_url
end
请参阅此 Railscast 的最后一部分:http: //asciicasts.com/episodes/188-declarative-authorization