Skip to content

Instantly share code, notes, and snippets.

@jheg
Created January 26, 2015 14:12
Show Gist options
  • Save jheg/bb1a6327fcd6f5884fa2 to your computer and use it in GitHub Desktop.
Save jheg/bb1a6327fcd6f5884fa2 to your computer and use it in GitHub Desktop.
rescue not being triggered
def set_category
if current_user
@category = current_user.categories.find(params[:id])
begin
rescue ActiveRecord::RecordNotFound
flash[:error] = "The category you're looking for could not be found."
redirect_to root_path
end
else
flash[:error] = 'You must be logged in to do that'
redirect_to root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment