select helpet selected value after failed save

I have a nested form, like:

<% form_for @invoice do |f| %>
<%= render :partial => "invoice_item_fields", :locals => {:f => f} %>
<% end %>

and _invoice_items_fields:

<% f.fields_for :invoice_items do |builder| %>
<%= link_to_remove_fields "remove", builder %>
<%= builder.collection_select(:product_id, Product.all, :id, :name) %>
<%= builder.text_field :quantity, :size => 4,%>
<% end %>

When i submit the form and it not pass the validations it render the new
action again. The thing is the selected value for :product_id is no
remembered, but the :quantity is ok. I read that i should setup an
instance variable in the controller with the value of the selected
option and then do something like:

<%= builder.collection_select(:product_id, Product.all, :id, :name,
:selected => @selected_product) %>

but the thing is the application could have many :invoice_items, so i
don't know what to do for the select field "remember" the values.

Thanks.