Sha256: ec28420740f6d88ed3244f898443894c10578e144eb01d0601c25d26e1ffec45

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

class ContactUs::Contact
  include ActiveModel::Validations

  validates_presence_of :email, :message

  # to deal with form, you must have an id attribute
  attr_accessor :id, :email, :message

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

  def read_attribute_for_validation(key)
    @attributes[key]
  end

  def to_key; end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contact_us-0.0.3 app/models/contact_us/contact.rb
contact_us-0.0.2 app/models/contact_us/contact.rb
contact_us-0.0.1 app/models/contact_us/contact.rb