# In\_place\_edit\_for in models

**URL:** <https://www.ruby-forum.com/t/in-place-edit-for-in-models/163625>\
**Category:** Rails\
**Created:** [March 23, 2009, 11:08am UTC](https://www.ruby-forum.com/t/in-place-edit-for-in-models/163625 "2009-03-23T11:08:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmswarna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rmswarna](https://www.ruby-forum.com/u/rmswarna)\
**Post date:** [March 23, 2009, 11:08am UTC](https://www.ruby-forum.com/t/in-place-edit-for-in-models/163625/1 "2009-03-23T11:08:58Z")

</div>

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

 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
else
  redirect_to(:controller => "session", :action => "sign_out")
end

```

end

end

and the view code is app/views/child\_user/show\_all.html.erb

# Your Kids

\<% @child\_users.each do |child| %\>

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

 <span id="child_user_name"><%= child.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 =\> child.id }, :update =\> “edit” %\>  
\<%= link\_to\_remote ‘Delete User’, :url =\> { :action =\>  
“confirm\_ajax”, :id =\> child.id }, :update =\> “confirm” %\>  
  
\<%= child.filter\_level.description %\>

hi
  

  

```
<% 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.

Regards,  
Swarna
