milan quendera
2005-Jun-14 13:27 UTC
A newbie question, find several documents but still can''t fiigure out....
My question is, if I have 2 tables, say, table_as has these 4 fields:: id foo table_bs_id comment and table_bs has 2 fields id name I want to list name( from_table_a''s_table_b_id) in my table_a ''s view, how could I do it? I try the following code in .rhtml , but don''t works (says can''t find table_b method) <% @table_as.each do |table_a| %> <tr> <td><%= link_to table_a.foo, :action => "show", :id => table_a.id %></td> <td><%= table_a.table_b.name %></td> <td><%= table_a.comment %></td> </tr> <% end %> and I wrote belongs_to and has_many in my models already..... please help~ _________________________________________________________________ 使用 MSN Messenger,與朋友在線上聊天: http://messenger.microsoft.com/tc
Duane Johnson
2005-Jun-14 14:25 UTC
Re: A newbie question, find several documents but still can''t fiigure out....
On Jun 14, 2005, at 7:27 AM, milan quendera wrote:> My question is, if I have 2 tables,What do your models look like? Duane Johnson (canadaduane) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails