我该如何跳出begin块并进入rescue块?
def function
begin
@document = Document.find_by(:token => params[:id])
next if @document.sent_at < 3.days.ago # how can I skip to the rescue block here?
@document.mark_as_viewed
rescue
flash[:error] = "Document has expired."
redirect_to root_path
end
end
我尝试使用next
,但没有成功。
rescue
关键词... - nzifnabdef...rescue...end
而不是def...begin...rescue...end...end
。 - kddeisz