Displaying 2 results from an estimated 2 matches for "line_item2".
Did you mean:
line_item
2006 Jul 20
1
Having issues saving line items to the DB
...has_many :line_items
LineItem
belongs_to :quote
...
@project = Project.new(params[:project])
@quote=Quote.new(params[:quote])
@line_items=[]
if params[:line_item1][''quantity_id''] != ''''
@line_items << LineItem.new(params[:line_item1])
end
if params[:line_item2][''quantity_id''] != ''''
@line_items << LineItem.new(params[:line_item2])
end
...
@quote.project=@project
@quote.line_items << @line_items
@quote.save
Problem
------------------------
I can get the project and quote models to save to the DB...
2006 Jul 01
3
best approach to add form elements dynamically
...the form elements for the
project and line_items, they can submit the form that will save the
project and line_items.
So far I have tried to use RJS to add a new line item. But seems like I
have to keep a tab of line_items added so far so that name for elements
for line_items like line_item1, line_item2 etc. So I have to pass each
time to the RJS call that can generate approriate form elememts and also
increment the line_item count. I was hoping to set a hidden element
containing the line_item count and use rjs replace that hidden element
every time the user adds a line_item.
This seems a lit...