Method: ActiveRecord::FinderMethods#find_sole_by
- Defined in:
- activerecord/lib/active_record/relation/finder_methods.rb
permalink #find_sole_by(arg, *args) ⇒ Object
Finds the sole matching record. Raises ActiveRecord::RecordNotFound if no record is found. Raises ActiveRecord::SoleRecordExceeded if more than one record is found.
Product.find_sole_by(["price = %?", price])
129 130 131 |
# File 'activerecord/lib/active_record/relation/finder_methods.rb', line 129 def find_sole_by(arg, *args) where(arg, *args).sole end |