Displaying 2 results from an estimated 2 matches for "child_documents".
2006 Mar 10
4
problem when looping through habtm children in a view
I have this code in a view:
<% for topic in @topics %>
<%= topic.id %> <%= topic.dr_title %><br/>
<ul>
<% for doc in topic.child_documents %>
<%= doc.dr_title %><br/>
<% doc = nil %>
<% end %>
</ul>
<% end %>
Though the topic titles and IDs display correctly, the child documents
for every topic are the same (the ones belonging to the first topic). In...
2006 Jan 03
0
habtm and insert_sql
...sing push_with_attributes. Is that possible?
Less briefly:
I have a legacy postgresql database where one of the join tables has an
ID column, so I had to set up the association with a custom :finder_sql
attribute, as follows:
class Topic < ActiveRecord::Base
[...]
has_and_belongs_to_many :child_documents, :class_name => "Document",
:join_table => "topic_subtopic",
:foreign_key => "topic_key", :association_foreign_key =>
"child_topic_key",
:finder_sql => ''select t.*, ts.display_header from topics t,
topic_subtopic ts where t....