Skip to content

Instantly share code, notes, and snippets.

@jonpaul
Created July 12, 2011 14:08
Show Gist options
  • Save jonpaul/1078051 to your computer and use it in GitHub Desktop.
Save jonpaul/1078051 to your computer and use it in GitHub Desktop.
contactu.rb
class Contactu
include ActiveModel::Validations
validates_presence_of :email, :name, :phone, :message
attr_accessor :id, :email, :phone, :name, :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?
UserMailer.contact_notification(self).deliver
return true
end
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment