4justinstewart
7/15/2015 - 5:19 PM

Find Unknown DB object by UUID

Find Unknown DB object by UUID

def find_unknown_object(uuid_string)

  db_connection = ActiveRecord::Base.connection

  db_connection.tables.each do |table_string|
    begin
      model = table_string.classify.constantize
      object = model.find(uuid)

      return object unless object.nil?
    rescue NameError #if no model exists
      next
    end
  end

end