在我的控制器中,我有一个 after_action 块。当相关方法失败时,我想停止 after_action 运行。
导轨 4.2,红宝石 2.2
有谁知道如何在rails中做到这一点?
class MyController < ApplicationController
after_action only: :show do
# do so and so
end
def show
begin
# something really bad happens here... My Nose!
rescue => e
# how do I stop after_action from running?
flash[:error] = 'Oh noes... Someone make a log report'
redirect_to '/'
return
end
# yarda yarda yarda
end
end