Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Controller file:
- class ContactsController < ApplicationController
- def new
- @contact = Contact.new
- end
- def create
- @contact=Contact.new(params[:contact])
- @contact.request=request
- if @contact.deliver
- flash.now[:error]=nil
- else
- flash.now[:error]='Cannot send message.'
- render :new
- end
- end
- <body>
- <section>
- <div class="container">
- <div class="row">
- <div class="col-lg-8 col-lg-offset-2 text-center">
- <h2 class="margin-top-0 wow fadeIn">Get in Touch</h2>
- <hr class="primary">
- <p>We love feedback. Fill out the form below and we'll get back to you as soon as possible.</p>
- </div>
- <div class="col-lg-10 col-lg-offset-1 text-center">
- <%= form_for @contact do |f| %>
- <div class="col-md-6 text-faded">
- <%= f.label :name %>
- <%= f.text_field :name, required: true, :class => "form-control", :placeholder => "Name"%>
- </div>
- <div class="col-md-6 text-faded">
- <%= f.label :email %>
- <%= f.email_field :name, required: true, :class => "form-control", :placeholder => "Email" %>
- </div>
- <div class="col-md-12 text-faded">
- <%= f.label :message %>
- <%= f.text_area :message, as: :text, :class => "form-control", :rows=>"9", :placeholder => "Your message here.."%>
- </div>
- <div class="hidden">
- <%= f.label :nickname %><br>
- <%= f.text_field :nickname, hint:"leave this field blank"%>
- </div>
- <div class="col-md-4 col-md-offset-4">
- <%= f.submit "Send Message", :class=> "btn btn-primary btn-block btn-lg" %>
- </div>
- <%end%>
- </div>
- </div>
- </div>
- </section>
- class Contact<MailForm::Base
- attribute :name, :validate => true
- attribute :email, :validate => /A([w.%+-]+)@([w-]+.)+([w]{2,})z/i
- attribute :message, :validate => true
- attribute :nickname,:captcha => true
- def headers
- {
- :subject => "Contact Form",
- :to => "kurtco_91@hotmail.com",
- :to => "yomi.89gm@gmail.com",
- :from => %("#{name}" <#email>)
- }
- end
- Rails.application.routes.draw do
- resources :contacts, only: [:new,:create]
- get 'gmm/home'
- get 'gmm/about'
- get 'gmm/services'
- get 'gmm/contact'
- get '/change_locale/:locale', to: 'settings#change_locale', as: :change_locale
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement