Rails 3. HABTM form select drop down menu
I have an invoice form. This is a simplified version: so it has line items where you select a drop down menu of product names.
This is working well: So the invoice-line_item relations is this: invoice has_many line_items and line_item belongs to invoice. line_item belongs to item and item has_many line_items. I have the items, line_items and invoice setup correctly.
But now I want to add taxes to the line items.
So I created a line_items_taxes table to create a HABTM relationship between line_items and taxes. But I can’t set it up correctly in the form. My form looks like this…
So I need a TAXES drop down select menu, and when the invoice is saved, it saves the tax for each line item.
undefined method merge for :name:Symbol
Your call to collection_select contains an extra parameter that is throwing things off. (Since I assume you are using *form_for*, the ‘line_item’ argument is automatically included, and yours is redundant.)
It should instead look something like this:
That’s a start in the right direction, anyway.