如何显示与惨惨在Rails3中活动页面上存取遭拒错误 [英] How to show AccessDenied errors on the active page with CanCan in Rails3
本文介绍了如何显示与惨惨在Rails3中活动页面上存取遭拒错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一种方法,在活动页面上显示我的闪存错误,而不 redirect_to的
方法。
顺便说一句,标准的闪存[:警惕] = exception.message
并没有给我任何错误信息,所以我改成了闪光灯[:错误]
感谢您的任何意见!
rescue_from惨惨::存取遭拒办|例外|
闪光[:错误] = exception.message
redirect_to的deadlines_path
结束
解决方案
尝试:
rescue_from惨惨::存取遭拒办|例外|
flash.now [:警惕] = exception.message
渲染something_else
返回false
结束
不重定向。
I am trying to find a way to display my flash errors on the active page without the redirect_to
method.
By the way, the standard flash[:alert] = exception.message
didn't show me any error messages, so I changed it to 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.
这篇关于如何显示与惨惨在Rails3中活动页面上存取遭拒错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文