Module: CrmLinkable

Extended by:
ActiveSupport::Concern
Included in:
Party
Defined in:
app/models/concerns/crm_linkable.rb

Overview

Shared CRM link generation for Party STI types.
Chooses the Rails URL helper from the model’s singular route key (customer, contact, etc.).

See Also:

Instance Method Summary collapse

Instance Method Details

Builds the CRM path or absolute URL for this record.

:reek:BooleanParameter :reek:ControlParameter

Parameters:

  • with_host (Boolean) (defaults to: false)

    when true, include host

  • host (String) (defaults to: CRM_HOSTNAME)

    hostname for absolute URLs

Returns:

  • (String)


16
17
18
19
20
21
22
23
# File 'app/models/concerns/crm_linkable.rb', line 16

def crm_link(with_host: false, host: CRM_HOSTNAME)
  route_key = model_name.singular_route_key
  if with_host
    UrlHelper.instance.public_send(:"#{route_key}_url", self, host:)
  else
    UrlHelper.instance.public_send(:"#{route_key}_path", self)
  end
end

Same as #crm_link with with_host: true.

Returns:

  • (String)


28
29
30
# File 'app/models/concerns/crm_linkable.rb', line 28

def crm_link_with_host
  crm_link(with_host: true)
end