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
26 27 28 |
# File 'app/models/gaku/contact.rb', line 26 def self.guardians where(contactable_type: Gaku::Guardian) end |
.primary ⇒ Object
43 44 45 |
# File 'app/models/gaku/contact.rb', line 43 def self.primary where(primary: true).first end |
.primary_email ⇒ Object
14 15 16 |
# File 'app/models/gaku/contact.rb', line 14 def self.primary_email where(primary: true, contact_type: Gaku::ContactType.where(name: 'Email').first).first end |
.secondary ⇒ Object
47 48 49 |
# File 'app/models/gaku/contact.rb', line 47 def self.secondary where(primary: false) end |
Instance Method Details
#make_primary ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/models/gaku/contact.rb', line 30 def make_primary contactable.contacts.where.not(id: id).update_all(primary: false) update_attribute(:primary, true) # if contactable.has_attribute?(:primary_contact) # contactable.update_attribute(:primary_contact, contactable.contact_widget) # end end |
#primary? ⇒ Boolean
39 40 41 |
# File 'app/models/gaku/contact.rb', line 39 def primary? primary end |
#to_s ⇒ Object
10 11 12 |
# File 'app/models/gaku/contact.rb', line 10 def to_s data end |