Class: ContactsController

Inherits:
Spree::BaseController
  • Object
show all
Defined in:
app/controllers/contacts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/contacts_controller.rb', line 13

def create
  @conversation = Conversation.create(:status => "open", :topic_id => params[:conversation][:topic])
  params[:contact][:conversation_id] = @conversation
  @contact = @conversation.contacts.build(params[:contact] || {})
  respond_to do |format|
    if verify_recaptcha(@contact) && @contact.valid? && @contact.save
      ContactMailer.message_email(@contact).deliver
      ContactMailer.message_received_email(@contact).deliver
      format.html { redirect_to(root_path, :notice => t("message_sent")) }
    else
      if @conversation.contacts.count == 0
        @conversation.destroy
      end
      format.html { render :action => "new" }
    end
  end
end

#editObject



9
10
11
# File 'app/controllers/contacts_controller.rb', line 9

def edit
  redirect_to new_contact_path
end

#newObject



4
5
6
7
# File 'app/controllers/contacts_controller.rb', line 4

def new
  @conversation = Conversation.new
  @contact = Contact.new(:conversation => @conversation)
end