Sha256: 349a9dc2d928c4b8e8257468eeeedb7f337306a9293516964aa42cda26a862aa

Contents?: true

Size: 992 Bytes

Versions: 12

Compression:

Stored size: 992 Bytes

Contents

module Spotlight
  ##
  # Controller for routing exhibit feedback from users
  class ContactFormsController < Spotlight::ApplicationController
    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
    before_action :build_contact_form

    def new
      @contact_form.current_url = request.referer
    end

    def create
      if @contact_form.valid?
        ContactMailer.report_problem(@contact_form).deliver_now

        redirect_back fallback_location: spotlight.new_exhibit_contact_form_path(current_exhibit), notice: t(:'helpers.submit.contact_form.created')
      else
        render 'new'
      end
    end

    protected

    def build_contact_form
      @contact_form = Spotlight::ContactForm.new(contact_form_params)
      @contact_form.current_exhibit = current_exhibit
      @contact_form.request = request
      @contact_form
    end

    def contact_form_params
      params.require(:contact_form).permit(:name, :email, :message, :current_url)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
blacklight-spotlight-0.30.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.29.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.29.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.28.3 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.28.2 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.28.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.28.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.27.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.26.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.26.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.25.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-0.24.0 app/controllers/spotlight/contact_forms_controller.rb