projects.each do |project|
begin
project.amount = amount
rescue
redirect_to :back
flash[:alert] = '出错了!'
end
project.save
end
redirect_to action: "index"
代码如上,我希望代码,如果抛出异常,在:
rescue
redirect_to :back
flash[:alert] = '出错了!'
end
这里就停止了,不要在往下执行,循环也停止。 请问需要添加些什么的呢?