Created
July 12, 2011 14:08
-
-
Save jonpaul/1078051 to your computer and use it in GitHub Desktop.
contactu.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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