Method: DataMapper::Collection#first_or_create
- Defined in:
- lib/dm-core/collection.rb
#first_or_create(conditions = {}, attributes = {}) ⇒ Resource
Finds the first Resource by conditions, or creates a new Resource with the attributes if none found
765 766 767 |
# File 'lib/dm-core/collection.rb', line 765 def first_or_create(conditions = {}, attributes = {}) first(conditions) || create(conditions.merge(attributes)) end |