ajout téléphone et lieu au formulaire
This commit is contained in:
parent
53aa3a8e47
commit
b46f6b0b54
@ -9,7 +9,7 @@ class Public::ContactsController < ApplicationController
|
|||||||
@contact = Contact.new
|
@contact = Contact.new
|
||||||
end
|
end
|
||||||
def create
|
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
|
if @contact.save
|
||||||
|
@ -3,5 +3,6 @@ class Contact < ActiveRecord::Base
|
|||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
||||||
validates :message, :presence => true
|
validates :message, :presence => true
|
||||||
|
validates :tel, :presence => true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,5 +3,7 @@
|
|||||||
=f.inputs do
|
=f.inputs do
|
||||||
=f.input :name, :label => "Nom :"
|
=f.input :name, :label => "Nom :"
|
||||||
=f.input :email, :label => "Email :"
|
=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.input :message, :label => "Message :"
|
||||||
=f.submit "Envoyer", :class => "btn"
|
=f.submit "Envoyer", :class => "btn"
|
@ -1,5 +1,12 @@
|
|||||||
%p
|
%p
|
||||||
Contact de
|
Contact de
|
||||||
%strong=@contact.name
|
%strong=@contact.name
|
||||||
|
|
||||||
|
%p
|
||||||
|
Téléphone
|
||||||
|
%strong=@contact.tel
|
||||||
|
%p
|
||||||
|
Lieu
|
||||||
|
%strong=@contact.place
|
||||||
%hr
|
%hr
|
||||||
=simple_format @contact.message
|
=simple_format @contact.message
|
5
db/migrate/20141106180846_add_place_to_contacts.rb
Normal file
5
db/migrate/20141106180846_add_place_to_contacts.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddPlaceToContacts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :contacts, :place, :string
|
||||||
|
end
|
||||||
|
end
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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|
|
create_table "admins", force: true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
@ -153,6 +153,7 @@ ActiveRecord::Schema.define(version: 20140719230318) do
|
|||||||
t.text "message"
|
t.text "message"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "place"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "content_types", force: true do |t|
|
create_table "content_types", force: true do |t|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user