Module: Citier4::RootClassMethods
- Defined in:
- lib/citier4/root_class_methods.rb
Instance Method Summary collapse
-
#find_by(*args) ⇒ Object
find_by and find_by! are exaclty the same defintion that ActiveRecord::FinderMethods see finder_methods.rb but it is not these function that are call by Post.find_by name: ‘Spartacus’, rating: 4 but the one that are define in ActiveRecord::Core So, theses methods are here just to overwrite the one in ActiveRecord::Core.
- #find_by!(*args) ⇒ Object
Instance Method Details
#find_by(*args) ⇒ Object
find_by and find_by! are exaclty the same defintion that ActiveRecord::FinderMethods
see finder_methods.rb
but it is not these function that are call by Post.find_by name: ‘Spartacus’, rating: 4 but the one that are define in ActiveRecord::Core So, theses methods are here just to overwrite the one in ActiveRecord::Core
23 24 25 26 27 |
# File 'lib/citier4/root_class_methods.rb', line 23 def find_by(*args) where(*args).take rescue RangeError nil end |
#find_by!(*args) ⇒ Object
28 29 30 31 32 |
# File 'lib/citier4/root_class_methods.rb', line 28 def find_by!(*args) where(*args).take! rescue RangeError raise RecordNotFound, "Couldn't find #{@klass.name} with an out of range value" end |