Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created January 25, 2011 06:49
Show Gist options
  • Save dangalipo/794581 to your computer and use it in GitHub Desktop.
Save dangalipo/794581 to your computer and use it in GitHub Desktop.
exception handling
def merge_suppliers
@supplier_from = Supplier.find(params[:id])
begin
@supplier_to = Supplier.find(params[:supplier_id])
rescue ActiveRecord::RecordNotFound
flash[:error] = "#{t('object.supplier')} #{t('messages.not_found')}"
redirect_to manage_supplier_path(@supplier_from.id)
end
render :merge_suppliers
end
@dangalipo
Copy link
Author

Ok basically what im trying to do is if it throws the not found except redirect back otherwise render the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment