Skip to content

Instantly share code, notes, and snippets.

@durran
Created July 6, 2011 16:34
Show Gist options
  • Save durran/1067682 to your computer and use it in GitHub Desktop.
Save durran/1067682 to your computer and use it in GitHub Desktop.
class User
include Mongoid::Document
has_many :cars do
def find_or_foobar_by(attrs)
find_or_create_by(attrs)
end
end
end
user.cars.find_or_foobar_by(attrs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment