In_place_edit_for in models

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

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