Module: AudiencesHelper

Defined in:
app/helpers/audiences_helper.rb

Overview

== Schema Information

Table name: audiences

id :integer not null, primary key
name :string
creator_id :integer
updater_id :integer
created_at :datetime not null
updated_at :datetime not null
customer_search_params :text
list_type :string
add_all_emails :boolean

View helpers for the CRM audiences pages.

Instance Method Summary collapse

Instance Method Details

#audience_command_options(_audience) ⇒ Array<String>

Note:

Operates on the +@audience+ ivar rather than the argument;
the delete link is only included when the current user can destroy it.

Builds the list of action links (edit, add members, match parties,
export, delete) shown in the commands dropdown for an audience.

Parameters:

  • _audience (Audience)

    unused; the audience is read from +@audience+

Returns:

  • (Array<String>)

    HTML links for the audience action menu



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/audiences_helper.rb', line 28

def audience_command_options(_audience)
  [].tap do |opts|
    opts << link_to(fa_icon('wrench', text: 'Edit'), edit_audience_path(@audience))
    opts << link_to(fa_icon('plus', text: 'Add New AudienceMembers'), new_audience_members_audience_path(@audience))
    if @audience.list_type == 'static'
      opts << link_to(fa_icon('user-tag', text: 'Match Contacts & Customers'),
                      backfill_parties_audience_path(@audience),
                      data: { turbo_method: :post,
                              turbo_confirm: 'Match every audience_member on this list to a contact (then customer) by email and store the resulting customer?' })
    end
    opts << link_to(fa_icon('rectangle-list', text: 'Export for ChatGPT'),
                    openai_export_audience_path(@audience),
                    data: { turbo_method: :post,
                            turbo_confirm: 'Build the hashed ChatGPT Ads CSV for this audience? Large lists take about a minute. The download starts when the job finishes.' })
    opts << link_to(fa_icon('trash', text: 'Delete'), audience_path(@audience), data: { turbo_confirm: "Are you sure?", turbo_method: :delete }) if can?(:destroy, @audience)
  end
end