Hallo,

folgende Situation: 

Models:

class A < ActiveRecord::Base
  has_one :b
  has_one :d
end 

class B < ActiveRecord::Base
  belongs_to    :a
  has_many      :c
end

class C < ActiveRecord::Base
  belongs_to :b
end 



Controller:
a_controller.rb:

@products = A.find :all, :include => [:b => :c]



View:
<% for product in @products -%>
  ...
  <% for item in a.b.c -%>
    <p><%=c.name %></p>
  <% end %>
<% end %>



Im View erscheint unter c.name nur eine einzige Zeile, obwohl die
(laut Log) durchgeführte SQL Abfrage alle entsprechenden Zeilen
zurück gibt. Wo ist mein Denkfehler? Bzw. gibt es noch andere Wege
dieses Problem so zu lösen, dass nur eine einzige SQL-Abfrage
ausgeführt wird? 

Google und API
(http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html)
konnten mir bisher nicht sonderlich weiterhelfen...

Vielen Dank im Voraus!

Michael


_______________________________________________
rubyonrails-ug mailing list
rubyonrails-ug@headflash.com
http://mailman.headflash.com/listinfo/rubyonrails-ug

Antwort per Email an