GAKUEngine/gaku

View on GitHub
core/app/models/concerns/contacts.rb

Summary

Maintainability
A
30 mins
Test Coverage
module Contacts
  extend ActiveSupport::Concern

  included do
    has_many :contacts, as: :contactable
    has_one :primary_contact, -> { where(primary: true) }, class_name: 'Gaku::Contact', as: :contactable

    # def primary_contact
    #   contacts.where(primary: true).first
    # end

    def contact_widget
      "#{primary_contact.contact_type}: #{primary_contact.data}" if primary_contact
    end
  end
end