Topic: Don't get access to associated Tables with .include()

Hey guys,

I'm a beginner in coding Rails and have a problem with joining tables. I have 2 models:

class Price < ActiveRecord::Base
  belongs_to :product
end

class Product < ActiveRecord::Base
  has_many :prices
end

Now I want to get a List of all Products with their prices. (One product has many prices, because I want to save price changes).

I tryed

Product.includes(:prices).all

but this only returns the whole Product table without the prices.

With .joins() it's the same.

Any suggestions?

Charon

Re: Don't get access to associated Tables with .include()

Try just

Product.includes(:prices)

See more details at:
http://asciicasts.com/episodes/181-include-vs-joins
http://guides.rubyonrails.org/active_re … rying.html