dblack / wobblini.net wrote: >> or this: >> >> def authenticate(login, pass) >> u = find(:first, :conditions => ["login = ? AND verified = 1 >> AND deleted = 0", login]) >> return nil if u.nil? > > A return in mid-method needs "return". You could avoid it by > rewriting the end of the method like this: > > if u.nil? > nil > else > other code > end > > But the "return nil if u.nil?" thing both terminates the method and > provides a visual cue that u being nil is a terminal condition. So > it's partly style, but once you decide to do a mid-method return, you > have to use "return". In this case a completely different solution is possible: def authenticate(login, pass) u = find(:first, :conditions => ["login = ? AND verified = 1 AND deleted = 0", login]) and find(:first, :conditions => ["login = ? AND salted_password = ? AND verified = 1", login, AuthenticatedUser.salted_password(u.salt, AuthenticatedUser.hashed(pass))]) end :-) robert