Created
January 15, 2014 16:35
-
-
Save borisd/8439500 to your computer and use it in GitHub Desktop.
Solutions to Validations
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
# Validate AGE is above 16 | |
# Validate First Name is longer than 5 characters | |
# Validate Username is unique | |
class User < ActiveRecord::Base | |
attr_accessible(:age, :first_name, :last_name, :username) | |
validates :age, numericality: { greater_than: 16 } | |
validates :first_name, length: { minimum: 5 } | |
validates :username, uniqueness: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment