Class: Household
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Household
- Defined in:
- app/models/household.rb
Instance Method Summary collapse
- #actions ⇒ Object
- #addresses ⇒ Object
- #lifetime_donations ⇒ Object
- #lifetime_donations_count ⇒ Object
- #lifetime_ticket_count ⇒ Object
- #lifetime_ticket_value ⇒ Object
- #lifetime_value ⇒ Object
- #notes ⇒ Object
- #tags ⇒ Object
- #update_member_addresses ⇒ Object
Instance Method Details
#actions ⇒ Object
37 38 39 |
# File 'app/models/household.rb', line 37 def actions Action.where(:person_id => individuals.pluck(:id)) end |
#addresses ⇒ Object
41 42 43 |
# File 'app/models/household.rb', line 41 def addresses Address.where(:person_id => individuals.pluck(:id)) end |
#lifetime_donations ⇒ Object
21 22 23 |
# File 'app/models/household.rb', line 21 def lifetime_donations individuals.sum(:lifetime_donations) end |
#lifetime_donations_count ⇒ Object
29 30 31 |
# File 'app/models/household.rb', line 29 def lifetime_donations_count individuals.includes(:orders).map { |i| i.orders.map { |o| o.donations.count }.sum }.sum end |
#lifetime_ticket_count ⇒ Object
25 26 27 |
# File 'app/models/household.rb', line 25 def lifetime_ticket_count Ticket.where(:buyer_id => individuals.pluck(:id)).count end |
#lifetime_ticket_value ⇒ Object
17 18 19 |
# File 'app/models/household.rb', line 17 def lifetime_ticket_value individuals.sum(:lifetime_ticket_value) end |
#lifetime_value ⇒ Object
13 14 15 |
# File 'app/models/household.rb', line 13 def lifetime_value individuals.sum(:lifetime_value) end |
#notes ⇒ Object
33 34 35 |
# File 'app/models/household.rb', line 33 def notes Note.where(:person_id => individuals.pluck(:id)) end |
#tags ⇒ Object
45 46 47 |
# File 'app/models/household.rb', line 45 def ActsAsTaggableOn::Tagging.where(:taggable_type => "Person", :taggable_id => individuals.pluck(:id)) end |
#update_member_addresses ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/household.rb', line 49 def update_member_addresses return unless address.present? individuals.each do |individual| if individual.address.present? individual.address.update_attributes(address.values_hash) else individual.address = address.dup end end end |