Class: Testimonials::TestimonialsController
- Inherits:
-
DashboardController
- Object
- DashboardController
- Testimonials::TestimonialsController
- Defined in:
- app/controllers/testimonials/testimonials_controller.rb
Overview
The testimonial queue: triage, search, best lines. Staff only.
POST to the mount path is SubmissionsController — the public write endpoint cannot share a controller with these, because this one inherits whatever the host set as base_controller_class.
Constant Summary collapse
- PER_PAGE =
50
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
38 39 40 41 |
# File 'app/controllers/testimonials/testimonials_controller.rb', line 38 def destroy @testimonial.destroy! redirect_to root_path, status: :see_other end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/testimonials/testimonials_controller.rb', line 14 def index @status = Testimonial::STATUSES.include?(params[:status]) ? params[:status] : 'pending' @kind = Testimonial::KINDS.include?(params[:kind]) ? params[:kind] : nil @query = params[:q].to_s.strip.presence @counts = tenant_scope.group(:status).count scope = tenant_scope.where(status: @status) scope = scope.where(kind: @kind) if @kind scope = search(scope) if @query @page = [params[:page].to_i, 1].max @testimonials = scope.newest_first.offset((@page - 1) * PER_PAGE).limit(PER_PAGE + 1).to_a @more = @testimonials.size > PER_PAGE @testimonials = @testimonials.first(PER_PAGE) @selected_testimonial = tenant_scope.find_by(id: params[:testimonial_id]) if params[:testimonial_id].present? end |
#show ⇒ Object
31 |
# File 'app/controllers/testimonials/testimonials_controller.rb', line 31 def show; end |
#update ⇒ Object
33 34 35 36 |
# File 'app/controllers/testimonials/testimonials_controller.rb', line 33 def update @testimonial.update!(admin_params) redirect_back fallback_location: testimonial_path(@testimonial), status: :see_other end |