# In place editing on a list - not passing ID through

**URL:** <https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204>\
**Category:** Rails\
**Created:** [August 12, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204 "2006-08-12T19:41:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 12, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/1 "2006-08-12T19:41:56Z")

</div>

I want to do in-place edits on a list of data, but I’m having trouble  
getting the ID passed through to the controller.

I use this in my view to create the field:

\<% for frame in @frames %\>  
…  
\<%= in\_place\_editor\_field :frame, :price %\>  
\<% end %\>

and this produces the following in my output:

0.0

I understand from some research that what I’m after is to replace  
“frame\_price\_\_in\_place\_editor” in both places with  
“frame\_price\_xx\_in\_place\_editor”, where “xx” is the id of the item to be  
updated, but I cannot figure out how to modify the call to  
in\_place\_editor\_field to pass the id in. I’ve tried the following with  
no luck…

\<%= in\_place\_editor\_field :frame, :price, :id =\> frame %\>  
\<%= in\_place\_editor\_field :frame, :price, :id =\> frame.id %\>  
\<%= in\_place\_editor\_field :frame, :price, {:id =\> frame} %\>  
\<%= in\_place\_editor\_field :frame, :price, {:id =\> frame.id} %\>

I’d appreciate any help.  
yb

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 12, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/2 "2006-08-12T19:54:21Z")

</div>

Have since discovered that I also need the URL in the Ajax call to  
include the id of the item to be updated, as such:

// ...where "xx" is the id of the item to be updated. Still having no luck. thanks. yb.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 12, 2006, 8:02pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/3 "2006-08-12T20:02:06Z")

</div>

I have since changed view code to the following…

\<%=in\_place\_editor\_field (:frame, :price, {:id =\>  
“frame\_price\_#{frame.id}\_in\_place\_editor”}, {:url =\>  
“/frames/set\_frame\_price/#{frame.id}”}) %\>

…and this appears to be accomplishing what I’m after, but seems  
extremely kludge-y.

Still wondering if there is a better way of doing this?

thanks.  
yb.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 12, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/4 "2006-08-12T21:06:32Z")

</div>

Cayce B. wrote:

> I have since changed view code to the following…
> 
> \<%=in\_place\_editor\_field (:frame, :price, {:id =\>  
> “frame\_price\_#{frame.id}\_in\_place\_editor”}, {:url =\>  
> “/frames/set\_frame\_price/#{frame.id}”}) %\>
> 
> …and this appears to be accomplishing what I’m after, but seems  
> extremely kludge-y.
> 
> Still wondering if there is a better way of doing this?
> 
> thanks.  
> yb.  
> \<removed\_email\_address@domain.invalid do |frame|%\>  
> \<%=frame.price%\>  
> \<%=in\_place\_editor(“price\_#{frame.id}”,  
> {:url =\> “/frames/set\_frame\_price/#{frame.id}”})%\>  
> \<%end%\>

In the controller:

def set\_frame\_price  
frame = Frame.find(params[:id])  
frame.price = params[:value]  
frame.save  
render :text =\> frame.price  
#i put a return in here once…baaaaaad results :]  
end

Hope this works

Ciao  
Gustav P.  
removed\_email\_address@domain.invalid

> **[ItsDex.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=itsdex.com)**
>
> We help you acquire the perfect domain for your site. Affordable payment options. Quick and responsive customer support available.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 13, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/5 "2006-08-13T18:26:47Z")

</div>

Thanks for the help!!!

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [August 12, 2006, 9:09pm UTC](https://www.ruby-forum.com/t/in-place-editing-on-a-list-not-passing-id-through/102204/6 "2006-08-12T21:09:02Z")

</div>

gustav Paul wrote:

> Cayce B. wrote:
> 
> > I have since changed view code to the following…
> > 
> > \<%=in\_place\_editor\_field (:frame, :price, {:id =\>  
> > “frame\_price\_#{frame.id}\_in\_place\_editor”}, {:url =\>  
> > “/frames/set\_frame\_price/#{frame.id}”}) %\>
> > 
> > …and this appears to be accomplishing what I’m after, but seems  
> > extremely kludge-y.
> > 
> > Still wondering if there is a better way of doing this?
> > 
> > thanks.  
> > yb.  
> > \<removed\_email\_address@domain.invalid do |frame|%\>  
> > \<%=frame.price%\>  
> > \<%=in\_place\_editor(“price\_#{frame.id}”,  
> > {:url =\> “/frames/set\_frame\_price/#{frame.id}”})%\>  
> > \<%end%\>
> 
> In the controller:
> 
> def set\_frame\_price  
> frame = Frame.find(params[:id])  
> frame.price = params[:value]  
> frame.save  
> render :text =\> frame.price  
> #i put a return in here once…baaaaaad results :]  
> end
> 
> Hope this works
> 
> Ciao  
> Gustav P.  
> removed\_email\_address@domain.invalid  
> [itsdEx.com](http://itsdEx.com)

I think the in\_place\_editor\_field helper works if you’ve only got one,  
in a list you need to somehow tell the different ones apart…one way is  
to use their ids

Gustav P.
