Class: Gaku::Contact
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gaku::Contact
- Defined in:
- app/models/gaku/contact.rb
Class Method Summary collapse
- .guardians ⇒ Object
- .primary ⇒ Object
- .primary_email ⇒ Object
- .secondary ⇒ Object
- .students ⇒ Object
- .teachers ⇒ Object
Instance Method Summary collapse
Class Method Details
.guardians ⇒ Object
31 32 33 |
# File 'app/models/gaku/contact.rb', line 31 def self.guardians where(contactable_type: Gaku::Guardian) end |
.primary ⇒ Object
48 49 50 |
# File 'app/models/gaku/contact.rb', line 48 def self.primary where(primary: true).first end |
.primary_email ⇒ Object
19 20 21 |
# File 'app/models/gaku/contact.rb', line 19 def self.primary_email where(primary: true, contact_type: Gaku::ContactType.where(name: 'Email').first).first end |
.secondary ⇒ Object
52 53 54 |
# File 'app/models/gaku/contact.rb', line 52 def self.secondary where(primary: false) end |
Instance Method Details
#make_primary ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/models/gaku/contact.rb', line 35 def make_primary contacts.where.not(id: id).update_all(primary: false) update_attribute(:primary, true) if contactable.has_attribute?(:primary_contact) contactable.update_attribute(:primary_contact, ) end end |
#primary? ⇒ Boolean
44 45 46 |
# File 'app/models/gaku/contact.rb', line 44 def primary? primary end |
#to_s ⇒ Object
15 16 17 |
# File 'app/models/gaku/contact.rb', line 15 def to_s data end |