Class: ContactPage::ContactMessagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/contact_page/contact_messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/contact_page/contact_messages_controller.rb', line 5

def index
	if request.post?
		@contact_message = ContactMessage.new(params[:contact_message])
  respond_to do |format|
    if @contact_message.save
      format.html { redirect_to root_path, notice: 'Tu mensaje ha sido enviado, gracias.' }
      format.json { render json: @contact_message, status: :created, location: @contact_message }
    else
      format.html { render action: "index" }
      format.json { render json: @contact_message.errors, status: :unprocessable_entity }
    end
  end
	else
		@contact_message = ContactMessage.new
		respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @contact_message }
  end
	end
end