I'm making a contact form in Rails 3 with this usefull example
I place my form on the main page, but when I'm trying to send message, page is redirecting to mysite.com/contact instead of mysite.com. Locally it works perfectly, but there is problem when it's deployed on Heroku. I believe that problem is in routes.rb, but I don't know how to solve it.
routes.rb
FirstApp::Application.routes.draw do
  root to: 'static_pages#home'
  match 'contact' => 'contact#new', as: 'contact', :via => :get
  match 'contact' => 'contact#create', as: 'contact', :via => :post
end
contact_controller.rb
class ContactController < ApplicationController
  def new
    @message = Message.new
  end
  def create
    @message = Message.new(params[:message])
    if @message.valid?
      NotificationsMailer.new_message(@message).deliver
      redirect_to(root_path, :notice => "Message was successfully sent.")
    else
      flash.now.alert = "Please fill all fields."
      render :new
    end
  end
end
message.rb
class Message
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend ActiveModel::Naming
  attr_accessor :name, :email, :subject, :body
  validates :name, :email, :subject, :body, :presence => true
  validates :email, :format => { :with => %r{.+@.+\..+} }, :allow_blank => true
  def initialize(attributes = {})
    attributes.each do |name, value|
      send("#{name}=", value)
    end
  end
  def persisted?
    false
  end
end
Thanks!
