Class: Testimonials::CollectionController

Inherits:
ApplicationController show all
Defined in:
app/controllers/testimonials/collection_controller.rb

Overview

The standalone public pages — the links you drop into an email or DM so people outside the app can answer: "#mount_path/new" for a testimonial, "#mount_path/nps/new" for the 0–10 score. Both are toggled by config.public_collection (ON by default); the NPS one also needs config.nps.

Instance Method Summary collapse

Instance Method Details

#npsObject

The same widget code, opened straight onto the NPS card. A promoter is offered the testimonial form right after scoring, inline on this page.



23
24
25
# File 'app/controllers/testimonials/collection_controller.rb', line 23

def nps
  head :not_found unless Testimonials.config.nps
end

#showObject



13
14
15
16
17
18
19
# File 'app/controllers/testimonials/collection_controller.rb', line 13

def show
  # A signed-in visitor edits their existing review (in this tenant)
  # instead of adding one.
  @existing = current_author_id &&
              Testimonial.for_tenant(current_tenant)
                         .where(author_id: current_author_id.to_s).newest_first.first
end