ブロックでレスキューを行う正しい方法ですか?レスキューブロックを行う最良の方法
また、それは最短ですか?
def rescue_definition
begin
user.begin_rescue
rescue Example::ParameterValidationError => e
redirect_to :back, error: e.message_to_purchaser
rescue Example::ProcessingError => e
redirect_to :back, error: e.message_to_purchaser
rescue Example::Error
redirect_to :back, error: e.message_to_purchaser
else
if user
flash['success'] = 'OK'
else
flash['error'] = 'NO'
end
end
redirect_to :back
end
お返事ありがとうございます。私はあなたの提案に従います。また、私は3回のレスキューで 'redirect_to:back、error:e.message_to_purchaser'を繰り返しています。それを行う最短の方法はありますか? – Bengala
@Bengalaこれが正解であれば、それを受け入れるべきです。 – mysmallidea
私は "redirect_to:back、error:e.message_to_purchaser"を3回繰り返しているので正解ではありません。私はそれがもっと短くてもいいと確信しています。 – Bengala