diff --git a/cookbook/015/hodgepodge/app/models/user.rb b/cookbook/015/hodgepodge/app/models/user.rb index 4a57cf0..796719a 100644 --- a/cookbook/015/hodgepodge/app/models/user.rb +++ b/cookbook/015/hodgepodge/app/models/user.rb @@ -1,2 +1,10 @@ class User < ActiveRecord::Base + validates_uniquness_of :username + validates_confirmation_of :password, :on => :create + validates_length_of :password, :within => 5..40 + + def self.authenticate(user_info) + find_by_username_and_password(user_info[:username], + user_info[:password]) + end end