anti spam prescription

This commit is contained in:
Nicolas Bally 2013-03-25 09:11:34 +01:00
parent 1f9a37ad60
commit 71b38f23b2
3 changed files with 19 additions and 10 deletions

View File

@ -11,6 +11,11 @@ class Public::PrescriptionsController < ApplicationController
@prescription = Prescription.new(params[:prescription])
@menu_item = MenuItem.find_by_permalink('ordonnances')
@title = @menu_item.name
if @prescription.email and @prescription.email != ""
redirect_to "/pages/ordonnances.html"
else
if @prescription.save
Notification.prescription_received.deliver
@ -20,5 +25,6 @@ class Public::PrescriptionsController < ApplicationController
render :template => "public/menu_items/show"
end
end
end
end

View File

@ -3,6 +3,9 @@ class Prescription < ActiveRecord::Base
mount_uploader :file, PrescriptionUploader
attr_accessor :email
attr_accessible :email, :tel, :name, :note
validates :name, :presence => true
validates :tel, :presence => true

View File

@ -1,7 +1,7 @@
-@prescription = @prescription || Prescription.new
=form_for @prescription, :url => create_prescription_path(), :html => {:multipart => true} do |form|
=form.text_field :email, :placeholder => "ne doit pas être remplis.", :style => "display:none;"
%h2 Etape 1 : Vos coordonnées
%table
%tr