Module: E9Crm::Model

Extended by:
ActiveSupport::Concern
Includes:
E9Rails::ActiveRecord::InheritableOptions
Defined in:
lib/e9_crm/model.rb

Overview

The User model associated with a Contact. The idea is that a Contact can be associated to many different logins/users (e.g. [email protected], [email protected]).

In the default setup the included model is treated as simply an email, and given a “type” such as Personal, Work, etc.

One and only one of these models should be considered “primary”. The designation of which is handled largely by the Contact class.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#create_contact_if_missing!Object



37
38
39
40
41
42
43
44
# File 'lib/e9_crm/model.rb', line 37

def create_contact_if_missing!
  return true unless contact.blank?

  # when creating a contact we should assume we're primary
  self.options.primary = true
  build_contact(create_contact_parameters)
  save
end

#primary?Boolean

Is this the Contact’s primary model?

Returns:

  • (Boolean)


33
34
35
# File 'lib/e9_crm/model.rb', line 33

def primary?
  ["true", true].member? options.primary
end