Created
September 17, 2011 03:34
-
-
Save andrusha/1223600 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 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