Skip to content

Instantly share code, notes, and snippets.

@johnnyworker1012
Created August 18, 2012 13:59
Show Gist options
  • Save johnnyworker1012/3386969 to your computer and use it in GitHub Desktop.
Save johnnyworker1012/3386969 to your computer and use it in GitHub Desktop.
tableless form class with validation
class BusinessLoginForm
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :email, :password
validates :email, :presence => true, :format => {:with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i,
:message => "Incorrect email address"}
validates :password, :presence => true, :length => { :minimum => 6 }
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment