Why redirect_to in around_filter or after_filter won't work?

后端 未结 3 619
天命终不由人
天命终不由人 2021-01-26 18:53

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           


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-26 19:36

    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 what around_filters were designed to do.

提交回复
热议问题