Skip to content

Instantly share code, notes, and snippets.

@andrusha
Created September 17, 2011 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrusha/1223600 to your computer and use it in GitHub Desktop.
Save andrusha/1223600 to your computer and use it in GitHub Desktop.
class User < ActiveRecord:Base
ROLE_TYPES = %W[Company Developer]
validates_presence_of :email, :allow_blank => false, :allow_nil => false
validates_uniqueness_of :email
validates_email_format_of :email
attr_accessible :email
end
class Developer < ActiveRecord::Base
acts_as_role
validates_numericality_of :phone_number, :allow_blank => true
attr_accessible :phone_number
end
class ApplicationController < ActionController::Base
def index
@user = Developer.new
end
end
= simple_form_for @user, :validate => true do |f|
=f.input :email, :required => true
=f.input :phone_number, :required => true
# In this example, only phone_number will be validated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment