Skip to content

Instantly share code, notes, and snippets.

@stevehodgkiss
Created October 25, 2010 13:00
Show Gist options
  • Save stevehodgkiss/644906 to your computer and use it in GitHub Desktop.
Save stevehodgkiss/644906 to your computer and use it in GitHub Desktop.
class ContactForm < Form
attr_accessor :name, :email, :message
validates_presence_of :name, :email, :message
def save
# do something
end
end
class Form
extend ActiveModel::Naming
extend ActiveModel::Translation
extend ActiveModel::Callbacks
include ActiveModel::Validations
include ActiveModel::Conversion
def initialize(params={})
params.each_pair do |attr, value|
self.send(:"#{attr}=", value)
end unless params.blank?
end
def new_record?
true
end
def persisted?
false
end
def id
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment