On 16 September 2014 18:22, frocco wrote:
> Hello,
>
> I have a products table that is related to category.
>
> category has many products.
>
> How do I query the products to also include the category?
>
> Once I do this, how to I show the category data in my template?
There is usually no need to
Thank you, got it working.
On Tuesday, September 16, 2014 1:27:27 PM UTC-4, Vivek Sampara wrote:
>
> Please look into this
> http://apidock.com/rails/ActiveRecord/QueryMethods/includes
>
> On Tue, Sep 16, 2014 at 10:52 PM, frocco >
> wrote:
>
>> Hello,
>>
>> I have a products table that is relat
As described here
http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations
I think what you want is something like
products = Product.includes(:category)
This will eager load the category association when you load the Product
objects. You must specify the inverse re
Please look into this
http://apidock.com/rails/ActiveRecord/QueryMethods/includes
On Tue, Sep 16, 2014 at 10:52 PM, frocco wrote:
> Hello,
>
> I have a products table that is related to category.
>
> category has many products.
>
> How do I query the products to also include the category?
>
> On
Hello,
I have a products table that is related to category.
category has many products.
How do I query the products to also include the category?
Once I do this, how to I show the category data in my template?
Thanks
--
You received this message because you are subscribed to the Google Group
5 matches
Mail list logo