sql help

I need to return a product title from an id. I’ve tried the following…

<%= Product.where( ['id =?', iu.product_id ]).select('title') %>

but it gives me a reference...

#<Product::ActiveRecord_Relation:0x007faca389eca0>


I've tried a number of things.

Any hints?

Thanks,
Joe

ok, I’ve got it working but…

 <%= Product.where( ['id =?', iu.product_id ]).pluck("title") %>


**It's got [' '] around my title.**


Hi,

Assuming that you have setup your relationships so that iu belongs_to product you can say

iu.product.title

Colin

Thanks. This worked.