instance method
find_by_attributes
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.2.22.5Signature
find_by_attributes(match, attributes, *args)
No documentation comment.
Parameters
-
matchreq -
attributesreq -
argsrest
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 261
def find_by_attributes(match, attributes, *args)
conditions = Hash[attributes.map {|a| [a, args[attributes.index(a)]]}]
result = where(conditions).send(match.finder)
if match.bang? && result.blank?
raise RecordNotFound, "Couldn't find #{@klass.name} with #{conditions.to_a.collect {|p| p.join(' = ')}.join(', ')}"
else
result
end
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 261
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods