Skip to content

Instantly share code, notes, and snippets.

@dmz006
Last active December 17, 2015 15:29
Show Gist options
  • Save dmz006/5632527 to your computer and use it in GitHub Desktop.
Save dmz006/5632527 to your computer and use it in GitHub Desktop.
multiple rails rescues in single method
def show
begin
@jobqueue = Delayed::Job.find(session[:jobqueue]) if session[:jobqueue]
rescue ActiveRecord::RecordNotFound
session[:jobqueue] = nil
return
end
if @jobqueue.nil? && session[:jobqueue]
session[:jobqueue] = nil
end
begin
@item = Item.find(params[:id]) if (params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to item_index_path
return
end
@categories = Category.find(:all, :order => "name")
respond_to do |format|
format.html
format.js
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment