Class: Crm::Customers::OnboardingController

Inherits:
CrmController
  • Object
show all
Defined in:
app/controllers/crm/customers/onboarding_controller.rb

Overview

Controller: onboarding.

Instance Method Summary collapse

Instance Method Details

#editObject

Renders the customer's onboarding form (templates + contact points).



16
17
18
19
20
# File 'app/controllers/crm/customers/onboarding_controller.rb', line 16

def edit
  authorize!(:manage, ExportedCatalogItemPacket)
  load_customer_record
  prepare_contact_points
end

#showObject

Lists a customer's exported catalog item packets, ransack-filtered
(defaulting to active packets only).



6
7
8
9
10
11
12
13
# File 'app/controllers/crm/customers/onboarding_controller.rb', line 6

def show
  authorize!(:manage, ExportedCatalogItemPacket)
  load_customer_record
  params[:q] ||= { inactive_eq: 0 }
  @q = @customer.exported_catalog_item_packets.ransack(params[:q])
  @q.sorts = 'updated_at DESC' if @q.sorts.blank?
  @pagy, @packets = pagy(@q.result, limit: params[:per])
end

#updateObject

Updates the customer's onboarding record from onboarding_params.



23
24
25
26
27
28
29
30
31
# File 'app/controllers/crm/customers/onboarding_controller.rb', line 23

def update
  authorize!(:manage, ExportedCatalogItemPacket)
  load_customer_record
  if @customer_record.update(onboarding_params)
    redirect_to_return_path_or_default customer_onboarding_path(@customer)
  else
    render :edit, status: :unprocessable_content
  end
end