NoMethodError when using find_by_sql

The object refered to by employee is likely not of the Employee model class. Try not overriding the :select list in your find and letting AR's associations do some of the heavy lifting:

Assuming associations to options and account:

class Employee < ActiveRecord::Base
   has_many :options
   belongs_to :account

   def self.authenticate username, password, account_code
     if employee = find(:first, :include => [ :account, :options ],
                       :conditions => [ "employees.deleted_yn = ?" +
                                        " AND employees.username = ?" +
                                        " AND accounts.account_code = ?",
                                        false, username, account_code ])
       expected_password = encrypted_password(password, employee.salt)
       if employee.hashed_password != expected_password
         employee = nil
       end
     end
     employee
   end
end

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com