Strange id value in ActiveRecord

Hi,

I’m experimenting a strange behaviour when trying to evalute the id of
an
ActiveRecord instance. The code below produces weird values:

user = Customer.find(@session[:customer].id)
products = user.orders.collect do |order|
order.orderItems.collect do |item|
logger.info('Product : ’ + item.product.id.to_s)
item.product
end.uniq
end
products.each { |p| logger.info http://logger.info 'Products ’ +
p.id.to_s}

The log inside the ‘collect’ produces the expected result (ids like 3, 4
or). But when I iterate on the resulting Array (products), my id values
are
something like:

Products -608103678
Products -608105008
Products -608106288
Products -608112128
Products -608115738

Do anybody have an idea of what is happening?

Thanks a lot for any help,

Matt.

Matthieu R. wrote:

user = Customer.find(@session[:customer].id)
products = user.orders.collect do |order|
  order.orderItems.collect do |item|
    logger.info('Product : ' + item.product.id.to_s)
    item.product
  end.uniq
end
products.each { |p| logger.info <http://logger.info> 'Products ' + 

p.id.to_s }

products will be an array of arrays. Instead of using collect in
the outer loop, you want to merge the inner arrays together, then
call uniq. At the moment you’re printing the Ruby id values of
the arrays that make up the products array.