Context:
I have a GoodsReturn model with many ReturnedItem. For the new view, I
create a new GoodsReturn with many new ReturnedItems from a sale (and
its SoldItems).
Problem:
I want to have a Add/Selected checkbox with which the user can pick
the items he wants to return. I know I could use a 'selected' virtual
attribute but I don't want to pollute my model just for this. In fact,
there is something that does exactly the opposite that I want,
the :_destroy:
<%= i_f.check_box :_destroy %>
I would like exactly the opposite, :_select.
sure is simple, i will tell you what i think you are trying to say and you can confirm it,
you have a list of items, and you want the user to be able to make a selection and remove them with checkboxes?
is that it?
I have a list of items (all are new_record? = true) that are nested
into another new record. I want the user to make a selection and ADD
them with checkboxes, not remove. Those without checkboxes will just
be discarded and never created.
oh i see, you can handle the way the hash is passed so that you can loop true the params and check for the selected one, then
only save the selected ones , i did something similar. You can handle the hash by adding to the field names in the for helper.
for example addin :value[whatever] associates the items and puts then in an array in the params hash