[英]How to show AccessDenied errors on the active page with CanCan in Rails3
I am trying to find a way to display my flash errors on the active page without the redirect_to
method. 我试图找到一种方法来在活动页面上显示我的Flash错误,而不需要redirect_to
方法。
By the way, the standard flash[:alert] = exception.message
didn't show me any error messages, so I changed it to flash[:error]
. 顺便说一句,标准的flash[:alert] = exception.message
没有显示任何错误消息,因此我将其更改为flash[:error]
。
Thanks for any advice! 感谢您的任何建议!
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
redirect_to deadlines_path
end
Try: 尝试:
rescue_from CanCan::AccessDenied do |exception|
flash.now[:alert] = exception.message
render 'something_else'
return false
end
without a redirect. 没有重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.