app/models/people/person.rb
def for(obj, unit = Unit.find_by_abbreviation("carlson"))
      unit_id = unit.nil? ? [1,9] : unit.id
      if obj.is_a? Quarter        
        includes(:position => {:organization_quarter => :organization}).where(organization_quarters: { quarter_id: obj.id, unit_id: unit_id})      
      else
        includes(:position => {:organization_quarter => :organization}).where(organization_quarters: { unit_id: unit_id}).where(["#{obj.class.name.foreign_key} = ? ", obj]) rescue []        
      end
    end
# Limit results to placements that are specifically connected to the supplied object. Object can be a Quarter, a 
# ServiceLearningPosition, or a ServiceLearningCourse.
# if unit is nil, we get placements from all units except pipeline
Limit results to placements that are specifically connected to the supplied object. Object can be a Quarter, a
ServiceLearningPosition, or a ServiceLearningCourse.
if unit is nil, we get placements from all units except pipeline
Limit results to placements that are specifically connected to the supplied object . Object can be a Quarter a ServiceLearningPosition or a ServiceLearningCourse . if unit is nil we get placements from all units except pipeline
def for(obj, unit = Unit.find_by_abbreviation("carlson"))
      unit_id = unit.nil? ? [1,9] : unit.id
      if obj.is_a? Quarter        
        includes(:position => {:organization_quarter => :organization}).where(organization_quarters: { quarter_id: obj.id, unit_id: unit_id})      
      else
        includes(:position => {:organization_quarter => :organization}).where(organization_quarters: { unit_id: unit_id}).where(["#{obj.class.name.foreign_key} = ? ", obj]) rescue []        
      end
    end
def for ( obj , unit = Unit . find_by_abbreviation ( "carlson" ) ) unit_id = unit . nil? ? [ 1 , 9 ] : unit . id if obj . is_a? Quarter includes ( :position => { :organization_quarter => :organization } ) . where ( organization_quarters : { quarter_id : obj . id , unit_id : unit_id } ) else includes ( :position => { :organization_quarter => :organization } ) . where ( organization_quarters : { unit_id : unit_id } ) . where ( [ "#{obj.class.name.foreign_key} = ? " , obj ] ) rescue [ ] end end
Limit results to placements that are specifically connected to the supplied object.
Limit results to placements that are specifically connected to the supplied object .
obj
unit
find_by_abbreviation