I wrote some code that searches ObjectSpace prior to initializing anobject to see if one of that type and some attributes is alreadypresent and uses that instead of initializing. (yes it's active recordand i am trying to avoid stale object errors). How horrible is this? Iam searching by specific class name so in practice it ends up lookingat at most a couple of instances but is there something inherentlywrong with doing this?
def find_in_space(search_id, search_version = nil) retval = nil ObjectSpace.each(Person){|person| retval = person if (p.id == search_id) && search_version && p.lock_version == search_version } return retval || Person.find(search_id)end
Mark