12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/testimonials/nps_controller.rb', line 12
def create
nps = NpsResponse.new(nps_params)
nps.locale = I18n.locale.to_s
nps.tenant = current_tenant
nps.user_agent = request.user_agent
attribute_author(nps)
if nps.save
PromptEvent.record!(kind: 'nps', action: 'submitted', tenant: current_tenant,
author_id: current_author_id, visitor_token: ensure_visitor_token)
notify_host(nps)
notify_detractor(nps) if nps.detractor?
render json: { offer_testimonial: offer_testimonial?(nps) }, status: :created
else
render json: { errors: nps.errors.full_messages }, status: :unprocessable_entity
end
end
|