Module: ActiveRecordFindByExtension::ClassMethods

Defined in:
app/models/active_record_find_by_extension.rb

Instance Method Summary collapse

Instance Method Details

#find_by(args) ⇒ Object

A Rails 4 alias for ‘where`. See: github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/finder_methods.rb

It will return the first matching object and return the object, not an ActiveRecord::Relation. If an ActiveRecord::Relation, which is chainable, is needed, use where().



12
13
14
# File 'app/models/active_record_find_by_extension.rb', line 12

def find_by( args )
  where( args ).limit( 1 ).first
end