Passing in each item.id in a method

Hi everyone, I am trying to implement the in_place_editor method and am
trying to pass in each item.id as the elementID argument. So I’m trying
to do something like this, <% in_place_editor(‘title_<%=item.id%>’,
:rows => “1”,…) %> But that doesn’t work. Here is my code,
http://rafb.net/paste/results/K5yFSG20.html My goal here is to be able
to make this in_place_editor work for each of the items in the list.
Any ideas??

Thanks in advance!

On 12/4/05, Jordan I. [email protected] wrote:

Hi everyone, I am trying to implement the in_place_editor method and am
trying to pass in each item.id as the elementID argument. So I’m trying
to do something like this, <% in_place_editor(‘title_<%=item.id%>’,
:rows => “1”,…) %> But that doesn’t work.

<% in_place_editor(“title_#{item.id}”, :rows => “1”,…) %>

Hi Jeremy, thanks for the reply. I did what you posted and I am getting
an error message saying ‘item’ is undefined. However, it works for
item.id earlier in the code? Any ideas? Sorry I am a noob at rails.
Here is my updated code with error message pasted in below:

http://rafb.net/paste/results/T4b8ew63.html

Thanks!

jeremyevans0 wrote:

On 12/4/05, Jordan I. [email protected] wrote:

Hi everyone, I am trying to implement the in_place_editor method and am
trying to pass in each item.id as the elementID argument. So I’m trying
to do something like this, <% in_place_editor(‘title_<%=item.id%>’,
:rows => “1”,…) %> But that doesn’t work.

<% in_place_editor(“title_#{item.id}”, :rows => “1”,…) %>

Ah you are right, it worked! Thanks for the help and the link!

jeremyevans0 wrote:

On 12/4/05, Jordan I. [email protected] wrote:

Hi Jeremy, thanks for the reply. I did what you posted and I am getting
an error message saying ‘item’ is undefined. However, it works for
item.id earlier in the code? Any ideas? Sorry I am a noob at rails.
Here is my updated code with error message pasted in below:

http://rafb.net/paste/results/T4b8ew63.html

item is defined as a local block variable earlier on in the code,
that’s why it works there. item is undefined when you use it later.
You may be able to get what you want by moving the sortable_element
and in_place_editor inside the block.

In any case, I’d pick up a good book on Ruby before you go much
further. There’s a free online one at
http://www.rubycentral.com/book/. It will explain variable scope
among other important issues.

On 12/4/05, Jordan I. [email protected] wrote:

Hi Jeremy, thanks for the reply. I did what you posted and I am getting
an error message saying ‘item’ is undefined. However, it works for
item.id earlier in the code? Any ideas? Sorry I am a noob at rails.
Here is my updated code with error message pasted in below:

http://rafb.net/paste/results/T4b8ew63.html

item is defined as a local block variable earlier on in the code,
that’s why it works there. item is undefined when you use it later.
You may be able to get what you want by moving the sortable_element
and in_place_editor inside the block.

In any case, I’d pick up a good book on Ruby before you go much
further. There’s a free online one at
http://www.rubycentral.com/book/. It will explain variable scope
among other important issues.