Created
October 25, 2010 13:00
-
-
Save stevehodgkiss/644906 to your computer and use it in GitHub Desktop.
This file contains 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 ContactForm < Form | |
attr_accessor :name, :email, :message | |
validates_presence_of :name, :email, :message | |
def save | |
# do something | |
end | |
end |
This file contains 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 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