Topic: Refactoring pointers
I'm going to have a crack at refactoring some redundant code I have in my controllers. I have the following three lines present in a number of methods that identifies a user from a browser environment variable and looks them up in my database's users table:
@kerberos = request.env["REMOTE_USER"]
username = ["kerberos LIKE ?", @kerberos]
@user = User.find(:first, :conditions => username)
How do I go about refactoring this into one method and calling that method in all the other methods that require this in my controller?