本文介绍了为什么redirect_to在around_filter或after_filter不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使redirect_to在这些过滤器中起作用?
我试图改变
def start
...
redirect_to索引
结束
结束
...
redirect_to索引
结束
到
around_filter:大约
def
...
收益
redirect_to索引
结束
开始
..
end
def stop
...
end
redirect_to 放在你需要的操作的最后来解决这个问题。这不是around_filters
被设计来做的。How to make redirect_to works in those filters?
I'm trying to change
def start .... redirect_to index end def end ... redirect_to index end
to
around_filter :around def around ... yield redirect_to index end def start .. end def stop ... end
解决方案After the action is complete it renders the template automatically, thus you cannot render / redirect after the request is complete. You could solve this by putting the
redirect_to
at the end of the actions that you need it for. This is not whataround_filters
were designed to do.这篇关于为什么redirect_to在around_filter或after_filter不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!