views:

78

answers:

1

I hope this is a simple - and perhaps embarrassingly dumb - question.

I have the following code that is generating fields for an invoice

THis is in the edit.html.erb for the invoice class

<% f.fields_for(:invoice_items)  do |f| %>
    <%= render :partial => 'invoice_items/fields', :locals => {:f => f} %>
<% end %>

and I generate the invoice_items as part of the invoice object

@invoice = Invoice.find(params[:id], :include => :invoice_items, :order =>"invoice_items.display_order")

It works just fine, but I need to wrap each one in a div, and assign that object's id to the div. (div id=i_2345 - that kind of thing) so I can use jQuery wizardry.

Where I am stumbling like a new-born foal is how do I access the the id of the invoice_item that is being called?

I can do a f.text_field :id and it gives me the correct id - so it knows it. But I am hoping there is some rails magic pixie dust I can sprinkle that will give it to me without having to rip that apart.

Any help would be v much appreciated. Thanks - Ben

+4  A: 

Yay - I love it when you find the answer about 20 mins after asking the question ...

f.object.id

Nothing to see here now - go back to your lives citizens ...

Ben R