0
我使用這個第三方控制器:導軌 - 攔截respond_with
class LibController
def update
# 29 lines of code
respond_with resource
end
end
我想要做的比respond_with
在結束其他的東西。但我不想將所有29行復制/粘貼到MyController.update
。可惜我不能想出一個辦法來渲染或重定向其他地方:
class MyController < LibController
def update
super
redirect_to somewhere_else
end
end
我得到了DoubleRenderError: Render and/or redirect were called multiple times in this action
。我認爲這是因爲respond_with
立即調用render
。有沒有辦法阻止/阻止?
謝謝!
感謝aldrien。我想知道如果我唯一的選擇是從第三方方法複製/粘貼整個方法,只是爲了替換最後一行。 – Matt
我想你只需要在Controller方法中使用重定向,並嘗試刪除「class LibController」中的respond_with。對不起,我只是猜測可能的方式,因爲我沒有看到你的完整代碼。嘗試操縱它,重要的是隻使用一個重定向。 –