Skip to content

Instantly share code, notes, and snippets.

@TheNicholasNick
Created March 11, 2009 01:35
Show Gist options
  • Save TheNicholasNick/77243 to your computer and use it in GitHub Desktop.
Save TheNicholasNick/77243 to your computer and use it in GitHub Desktop.
class BaseModel < CouchRest::ExtendedDocument
# I like nil instead of Exceptions when resources can not be found.
def self.get(id)
begin
super
rescue RestClient::ResourceNotFound
nil
end
end
end
class User < BaseModel
# now User.get("bogus_id") returns nil - win!
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment