In place editing on a list - not passing ID through

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

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.

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.

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.
<[email protected] 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.
[email protected]
itsdEx.com

Thanks for the help!!!

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.
<[email protected] 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.
[email protected]
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs