Skip to content

Instantly share code, notes, and snippets.

@maiha
Created February 20, 2010 06:02
Show Gist options
  • Save maiha/309536 to your computer and use it in GitHub Desktop.
Save maiha/309536 to your computer and use it in GitHub Desktop.
# sinatra syntax is cool!
get "/users/:id" do
@user = User.find(params[:id])
haml :user
end
# become ugly when error handling is added
get "/users/:id" do
begin
@user = User.find(params[:id])
haml :user
rescue ActiveRecord::RecordNotFound
return "not found"
end
end
# stay cool if "do" accept "rescue/esnure"
get "/users/:id" do
@user = User.find(params[:id])
haml :user
rescue ActiveRecord::RecordNotFound
return "not found"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment