diff options
Diffstat (limited to 'app/models/contact_validator.rb')
-rw-r--r-- | app/models/contact_validator.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb index 830ba3019..d01f186a3 100644 --- a/app/models/contact_validator.rb +++ b/app/models/contact_validator.rb @@ -15,13 +15,10 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -class ContactValidator < ActiveRecord::BaseWithoutTable - strip_attributes! +class ContactValidator + include ActiveModel::Validations - column :name, :string - column :email, :string - column :subject, :text - column :message, :text + attr_accessor :name, :email, :subject, :message validates_presence_of :name, :message => N_("Please enter your name") validates_presence_of :email, :message => N_("Please enter your email address") @@ -29,6 +26,12 @@ class ContactValidator < ActiveRecord::BaseWithoutTable validates_presence_of :message, :message => N_("Please enter the message you want to send") validate :email_format + def initialize(attributes = {}) + attributes.each do |name, value| + send("#{name}=", value) + end + end + private def email_format |