0
與這些協會;請求關聯的對象並將它們放入一個實例變量?
- 產品belongs_to的:事情
- 事情的has_many:產品
已經選擇多個對象是這樣的:
@products = Product.find(1,2,3)
我怎麼會去他們的相應的另一關聯對象請求實例變量?因爲這樣的:
@things = (the things of product 1,2 and 3)
與這些協會;請求關聯的對象並將它們放入一個實例變量?
已經選擇多個對象是這樣的:
@products = Product.find(1,2,3)
我怎麼會去他們的相應的另一關聯對象請求實例變量?因爲這樣的:
@things = (the things of product 1,2 and 3)
@things = @products.collect(&:thing)
只有這個問題是: 當產品1屬於thing1 和產品2屬於還thing1 我得到兩次thing1而我只想要一個 – elkalto23 2011-02-14 16:06:16