Created
January 26, 2015 14:12
-
-
Save jheg/bb1a6327fcd6f5884fa2 to your computer and use it in GitHub Desktop.
rescue not being triggered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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