Created
January 10, 2012 17:07
-
-
Save nickhoffman/1590041 to your computer and use it in GitHub Desktop.
An alternative to halting in a helper
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
get '/users/:user_id/projects/:project_id/tasks-due-on/:task_date' do | |
user = User.find(params[:user_id]) | |
halt 404 unless user | |
project = user.projects.find(params[:project_id]) | |
halt 404 unless project | |
# etc... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see why error handling and the happy path should be separated, though. You don't split them in model methods, so why split them in controller actions?
Yes, multiply-nested conditionals are fugly. However, as I've shown above, they're not necessary.