class Contact include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :name, :email, :subject, :body validates_presence_of :name validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i validates_presence_of :email validates_presence_of :subject validates_presence_of :body def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end def persisted? false end end