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