There are rfq, quote and test_item in our rails 3.1.0 app. RFQ has many quotes and test items. Quote belongs to a rfq and has many test items. Test item has many rfqs and quotes.
When creating a quote, the test items in the rfq are passed into the quote new form directly. Here is the code in new in quotes controller:
@quote = @rfq.quotes.new()
@quote.test_items << @rfq.test_items
Here is the view code in quote new form for displaying the test items passed from the rfq:
<%= simple_form_for([@rfq, @quote]) do |f| %>
....
<% @quote.test_items.each do |t| %>
<p><%= f.association :test_items, :label => false %><%= link_to_remove_fields "remove", f %></p>
<% end %>
....
<% end %>
The view code above can display the test item passed from the rfq and maintain the association (quote has many test items) which is what the app needs. However it also displays a selection box for test item which is not needed here(can't change the test item in quote other than delete. Also t in the loop hasn't been useful). What we need is only to display the name of the test items, maintain the association (quote has many test items) and allow to delete test item (done by link_to_remove_fields).
Is there a clean way to accomplish this? Thanks so much.