Advertisement
Guest User

Untitled

a guest
Jan 4th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Controller file:
  2.  
  3. class ContactsController < ApplicationController
  4. def new
  5. @contact = Contact.new
  6. end
  7.  
  8. def create
  9. @contact=Contact.new(params[:contact])
  10. @contact.request=request
  11. if @contact.deliver
  12. flash.now[:error]=nil
  13. else
  14. flash.now[:error]='Cannot send message.'
  15. render :new
  16. end
  17. end
  18.  
  19. <body>
  20. <section>
  21. <div class="container">
  22. <div class="row">
  23. <div class="col-lg-8 col-lg-offset-2 text-center">
  24. <h2 class="margin-top-0 wow fadeIn">Get in Touch</h2>
  25. <hr class="primary">
  26. <p>We love feedback. Fill out the form below and we'll get back to you as soon as possible.</p>
  27. </div>
  28. <div class="col-lg-10 col-lg-offset-1 text-center">
  29. <%= form_for @contact do |f| %>
  30. <div class="col-md-6 text-faded">
  31. <%= f.label :name %>
  32. <%= f.text_field :name, required: true, :class => "form-control", :placeholder => "Name"%>
  33. </div>
  34. <div class="col-md-6 text-faded">
  35. <%= f.label :email %>
  36. <%= f.email_field :name, required: true, :class => "form-control", :placeholder => "Email" %>
  37. </div>
  38. <div class="col-md-12 text-faded">
  39. <%= f.label :message %>
  40. <%= f.text_area :message, as: :text, :class => "form-control", :rows=>"9", :placeholder => "Your message here.."%>
  41. </div>
  42. <div class="hidden">
  43. <%= f.label :nickname %><br>
  44. <%= f.text_field :nickname, hint:"leave this field blank"%>
  45. </div>
  46. <div class="col-md-4 col-md-offset-4">
  47. <%= f.submit "Send Message", :class=> "btn btn-primary btn-block btn-lg" %>
  48. </div>
  49. <%end%>
  50. </div>
  51. </div>
  52. </div>
  53. </section>
  54.  
  55. class Contact<MailForm::Base
  56. attribute :name, :validate => true
  57. attribute :email, :validate => /A([w.%+-]+)@([w-]+.)+([w]{2,})z/i
  58. attribute :message, :validate => true
  59. attribute :nickname,:captcha => true
  60.  
  61. def headers
  62. {
  63. :subject => "Contact Form",
  64. :to => "kurtco_91@hotmail.com",
  65. :to => "yomi.89gm@gmail.com",
  66. :from => %("#{name}" <#email>)
  67. }
  68. end
  69.  
  70. Rails.application.routes.draw do
  71.  
  72. resources :contacts, only: [:new,:create]
  73.  
  74. get 'gmm/home'
  75.  
  76. get 'gmm/about'
  77.  
  78. get 'gmm/services'
  79.  
  80. get 'gmm/contact'
  81.  
  82. get '/change_locale/:locale', to: 'settings#change_locale', as: :change_locale
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement