From 6f9519fce9a6fd0100386e6b5139e224ceff6af0 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 9 Aug 2011 21:40:23 -0400 Subject: [PATCH] filling in the user model --- cookbook/015/hodgepodge/app/models/user.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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