ajout téléphone et lieu au formulaire

This commit is contained in:
Nicolas Bally 2014-11-06 19:13:53 +01:00
parent 53aa3a8e47
commit b46f6b0b54
6 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddPlaceToContacts < ActiveRecord::Migration
def change
add_column :contacts, :place, :string
end
end

View File

@ -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|