diff --git a/app/controllers/public/contacts_controller.rb b/app/controllers/public/contacts_controller.rb index 1342421..13e0b51 100644 --- a/app/controllers/public/contacts_controller.rb +++ b/app/controllers/public/contacts_controller.rb @@ -9,7 +9,7 @@ class Public::ContactsController < ApplicationController @contact = Contact.new end def create - @contact = Contact.new(params.require(:contact).permit(:website, :name, :email, :message)) + @contact = Contact.new(params.require(:contact).permit(:website, :place, :tel, :name, :email, :message)) if @contact.save diff --git a/app/models/contact.rb b/app/models/contact.rb index 4f6cf94..ea4833f 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -3,5 +3,6 @@ class Contact < ActiveRecord::Base validates :name, :presence => true validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates :message, :presence => true + validates :tel, :presence => true end diff --git a/app/views/public/contacts/_form.html.haml b/app/views/public/contacts/_form.html.haml index 73529e4..71648d5 100644 --- a/app/views/public/contacts/_form.html.haml +++ b/app/views/public/contacts/_form.html.haml @@ -3,5 +3,7 @@ =f.inputs do =f.input :name, :label => "Nom :" =f.input :email, :label => "Email :" + =f.input :tel, :label => "Téléphone :" + =f.input :place, :label => "Lieu de votre projet :" =f.input :message, :label => "Message :" =f.submit "Envoyer", :class => "btn" \ No newline at end of file diff --git a/app/views/question_mailer/send_contact.html.haml b/app/views/question_mailer/send_contact.html.haml index 8f08547..f36649d 100644 --- a/app/views/question_mailer/send_contact.html.haml +++ b/app/views/question_mailer/send_contact.html.haml @@ -1,5 +1,12 @@ %p Contact de %strong=@contact.name + +%p + Téléphone + %strong=@contact.tel +%p + Lieu + %strong=@contact.place %hr =simple_format @contact.message \ No newline at end of file diff --git a/db/migrate/20141106180846_add_place_to_contacts.rb b/db/migrate/20141106180846_add_place_to_contacts.rb new file mode 100644 index 0000000..0990994 --- /dev/null +++ b/db/migrate/20141106180846_add_place_to_contacts.rb @@ -0,0 +1,5 @@ +class AddPlaceToContacts < ActiveRecord::Migration + def change + add_column :contacts, :place, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 159250f..e0e88a9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140719230318) do +ActiveRecord::Schema.define(version: 20141106180846) do create_table "admins", force: true do |t| t.string "name" @@ -153,6 +153,7 @@ ActiveRecord::Schema.define(version: 20140719230318) do t.text "message" t.datetime "created_at" t.datetime "updated_at" + t.string "place" end create_table "content_types", force: true do |t|