Forum: Ruby on Rails In_place_edit_for in models

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Swarna P. (Guest)
on 2009-03-23 12:08
Hi all,

         I am new to RoR. At present I am working with Ajax. I have
doubt in place_editing.

          Kindly please help me in this regard. I am struggling with
this for past one week.

           Any help from your side will be very helpful.

 I have a model called child_users. I am listing all the children for
the logged in User using <div> tags.

The code is as follows app/controllers/child_user_controller.rb

class ChildUserController < ApplicationController

  in_place_edit_for :child_user, :name

      def show_all
    @parent_user = User.find(SessionController.user)
    if @parent_user
      @child_users = @parent_user.child_users
      redirect_to(:controller => "session", :action => "sign_out")


and the view code is app/views/child_user/show_all.html.erb

<h1>Your Kids</h1>

<% @child_users.each do |child| %>

    <div class="userbox">
          <img src="images/ashley.jpg" align="left" />

     <span id="child_user_name"><%= -%> </span>
    <%= in_place_editor "child_user_name", :url => {:controller =>
:child_user, :action => 'set_child_user_name', :id => child} %>

                 <%= link_to_remote 'Edit', :url => { :action => "edit",
:id => }, :update => "edit" %>
                <%= link_to_remote 'Delete User', :url => { :action =>
"confirm_ajax", :id => }, :update => "confirm" %><br/>
     <%= child.filter_level.description %> <br/>
               <div id="edit">hi</div>

    <% end %>

As shown above, I tried to implement my own ajax based Edit. But the div
is displayed only in the first child. When edit link is clicked in the
second child, the div again opens only in the first child's div and not
in the corresponding child.

 Hence i tried using in_place_edit but the same problem happens. Only
the first child is editable. If clicked, it displays around 5 text
boxes(i.e. number of children for the user). The next child doesnt have
the click option at all.

What mistake am i doing. Can anyone help me please.

I ma struggling with this a lot. Thanks for all help.

This topic is locked and can not be replied to.