2009/9/6 maximulus <[email protected]>:
>
> Hello,
>
> I'm clearly missing some bit of code, but I can't figure out what.
> There are three models: Invoice, Lineitems and items. I want the user
> to search a list of items, and then add them to the lineitems table.
> The seach works, an provides a list on this form:
>
>
>  <% form_for :lineitems, :url => {:action => 'create', :id=>
> @invoice.id} do |f|-%>
>  <table>
>
>    <% @items.each do |item| %>
>
>    <tr>
>      <td><%=item.itemname %></td> <%=
> f.hidden_field :item_id, :value=>item.id %>

Probably nothing to do with your problem but I believe that input
fields (hidden or not) are not allowed between td elements.  To check,
view the source of the page in the browser and cut and paste the whole
thing into the html validation service at
http://validator.w3.org/#validate_by_input.  It may work ok as you
have it in one browser but not another.  I imagine you can put it
inside the cell.

Colin

>      <td><%= f.text_field :quantity %></td>
>      <td><%= f.text_field :price, :value => item.sellprice %></td>
>
>      <td><%= f.submit 'Add Item' %> </td>
>    </tr>
>      <% end %>
>
> When you click 'Add Item', it submits for that last item on the list,
> not the corresponding item.
>
> Controller code for create is:
> @invoice  = Invoice.find(params[:id])
>
> @lineitems = @invoice.lineitems.new(params[:lineitems])
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to