Sha256: ba7b58ed0378067e4d05bad8359e5202dabcdd938aee84fdfbc7fe7c261f6495

Contents?: true

Size: 599 Bytes

Versions: 4

Compression:

Stored size: 599 Bytes

Contents

class ContactUs::Contact
  include ActiveModel::Conversion
  include ActiveModel::Validations

  attr_accessor :email, :message

  validates :email,   :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i },
                      :presence => true
  validates :message, :presence => true

  def initialize(attributes = {})
    attributes.each do |key, value|
      self.send("#{key}=", value)
    end
  end

  def save
    if self.valid?
      ContactUs::ContactMailer.contact_email(self).deliver
      return true
    end
    return false
  end
  
  def persisted?
    false
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contact_us-0.1.5 app/models/contact_us/contact.rb
contact_us-0.1.4 app/models/contact_us/contact.rb
contact_us-0.1.3 app/models/contact_us/contact.rb
contact_us-0.1.2 app/models/contact_us/contact.rb