Class: PagesCms::ContactsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper
Defined in:
app/controllers/pages_cms/contacts_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#account, #blog_path, #current_account, #current_site, #insert_html_breaks, #meta_description, #meta_tags, #slugged_path

Methods inherited from ApplicationController

#current_account, #selected_account

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/pages_cms/contacts_controller.rb', line 7

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