Created
October 10, 2010 23:48
-
-
Save foca/619713 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # :facepalm: | |
| class User < ActiveRecord::Base | |
| validate do |user| | |
| if user.login.blank? | |
| user.errors.add_to_base("User Name can't be blank") | |
| else | |
| user.errors.add_to_base("User Name is too short(Minimum is 3 characters)") if user.login.length<3 and user.login.length !=0 | |
| user.errors.add_to_base("User Name is too long(Maximum is 3 characters)") if user.login.length>40 | |
| user.errors.add_to_base("User Name has already been taken.") if User.find_by_login(user.login) | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The worst thing is that two lines above from that there are calls to
validates_uniqueness_ofandvalidates_presence_of:P