Sha256: a7494d49480586636142ca06a56b70c9de5395eeadcdc6d9e98a56a7bb2069c0
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
# frozen_string_literal: true class TestimonialsController < ApplicationController before_action :find_structure before_action :authenticate_account!, only: [:new, :create] before_action :build_testimonial, only: [:new, :create] caches_page :index before_action :reset_cache, except: [:index] respond_to :js, only: [:create] def index @text = page_text('testimonials-text') params[:per] = 10 if params[:per].blank? || params[:per].to_i < 1 @testimonials = Testimonial.past.visible.local.page(params[:page]).per(params[:per]) respond_with @testimonials end def search @text = page_text('testimonials-text') params[:per] = 10 if params[:per].blank? || params[:per].to_i < 1 @testimonials = Testimonial.past.visible.local.order_first(params[:id]).page(params[:page]).per(params[:per]) respond_with @testimonials, template: 'testimonials/index' end def new @text = page_text('testimonials-text', :footer) respond_with(@testimonial) end def create @testimonial.remote_ip = request.remote_ip @testimonial.account_id = current_account.id @testimonial.update_attributes(testimonial_params) # create report in crm TranslationCms::Api::Report.create_from_params(testimonial_params, ReportType.review) respond_with @testimonial, location: testimonials_path end private def build_testimonial @testimonial = Testimonial.build_from_customer(current_account) end def find_structure load_structure(StructureType.testimonials) end def authenticate_account! unless account_signed_in? store_location_for(:account, new_testimonial_path) redirect_to new_account_session_path end end def testimonial_params params.require(:testimonial).permit(:name, :content, :email) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/controllers/testimonials_controller.rb |