Created
February 25, 2009 19:00
-
-
Save mattpolito/70348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When new line link is pressed, I get a new line to appear in my table... but the attributes for the new line are always the same as the first (invoice[line_attributes][new_1]) | |
What am I missing? | |
## app/views/invoices/new.html.haml | |
- form_for @invoice do |invoice_form| | |
= invoice_form.error_messages | |
= render :partial => 'invoice', :object => invoice_form | |
.field | |
= invoice_form.submit 'Save Invoice' | |
## app/views/invoices/_invoice.html.haml | |
%tbody#invoice_line_item_rows | |
- invoice.fields_for :lines do |line_fields| | |
= render :partial => 'line', :object => line_fields | |
= add_line_item_link('Add new line', @client) | |
## app/views/invoices/_line.html.haml | |
%tr | |
%td.item.delete.first | |
%td.item.kind= line.collection_select :line_type_id, LineType.all, :id, :name | |
%td.item.quantity= line.text_field :quantity, :size => 4, :class => "text limited" | |
%td.item.description= line.text_area :description | |
%td.item.tax= line.check_box :has_tax | |
%td.item.price= line.text_field :unit_price, :size => 8, :class => "text limited" | |
%td.item.total.last | |
## app/helpers/invoices_helper.rb | |
def add_line_item_link(name, invoice) | |
link_to_function name do |page| | |
page.insert_html :bottom, :invoice_line_item_rows, :partial => 'line', :object => invoice.lines.build | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment