SELECT * FROM foo WHERE id IS NULL;
MySQL has a known bug that will cause this to return the last row inserted into the DB, ie. something random, instead of what you are looking for. This is fixed in MySQL version 5.0.25 which will probably be in our next upgrade. Until then:
do this:
def find_user_by_id(user_id)
return nil if user_id == nil
@user ||= User.find_by_id(user_id )
@user
end
not this:
def find_user_by_id(user_id)
@user ||= User.find_by_id(user_id )
@user
end
For more information, see...
http://bugs.mysql.com/bug.php