Sha256: 9881e4596c2c1be493134a0b839a590079cec38060ef444d42d77c52b5e8f25f

Contents?: true

Size: 900 Bytes

Versions: 7

Compression:

Stored size: 900 Bytes

Contents

require_dependency "pages_cms/application_controller"

module PagesCms
  class ContactsController < ApplicationController
    include ApplicationHelper

    def create
      contact = current_site.contacts.build(contact_params)
      if contact.save
        begin
          ContactMailer.new_contact(contact).deliver
          flash[:success] = 'Successfully contacted us. We will respond shortly!'
        rescue Exception => e
          flash[:success] = 'Successfully contacted us. We will respond shortly.'
        end
        flash[:success] = 'Successfully contacted us. We will respond shortly!'
        redirect_to :back
      else
        flash[:danger] = "There was a problem: #{contact.errors.full_messages.to_sentence}"
        redirect_to :back
      end
    end

    private
      def contact_params
        params.require(:contact).permit(:name, :email, :message)
      end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pages_cms-2.2.3 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.2.2 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.2.1 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.1.1 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.1.0 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.0.1 app/controllers/pages_cms/contacts_controller.rb
pages_cms-2.0.0 app/controllers/pages_cms/contacts_controller.rb