Method: ActsAs::ClassMethods#where
- Defined in:
- lib/acts_as.rb
#where(opts = :chain, *rest) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/acts_as.rb', line 60 def where(opts = :chain, *rest) relation = super #TODO support nested attribute joins like Guns.where(rebels: {strength: 10})) # for now, only first level joins will happen automagically if opts.is_a? Hash detected_associations = opts.keys.map {|attr| acts_as_fields_match(attr) } .reject {|attr| attr.nil?} return relation.joins(detected_associations) if detected_associations.any? end relation end |