instance method
find_by!
Ruby on Rails 4.2.9
Since v4.0.13Signature
find_by!(*args)
Like find_by, except that if no record is found, raises an ActiveRecord::RecordNotFound error.
Parameters
-
argsrest
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 91
def find_by!(*args)
where(*args).take!
rescue RangeError
raise RecordNotFound, "Couldn't find #{@klass.name} with an out of range value"
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 91
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods