I am trying to do the crud operation with ajax effect.
In case of delete operation 1st selected data is deleted
bt in case of next data is not deleted in web page though it is deleted
from
database.
Here I use one controller and and use 3 view page(*.html.erb)
my index page…in student(controller)…
Form_Remote_Tag Test <%= javascript_include_tag :defaults %> <% form_remote_tag :url=>{:controller=>'student',:action=>'add'}, :update=>:adds, :complete => visual_effect(:highlight, 'adds') do %> Name <%=text_field 'school','name' %><br>
Name <%=text_field 'school','age' %><br>
<%=submit_tag(“Display”) %>
<% end %>
student page…
<% for sch in @schools %>
<%= h sch.name %> | <%= h sch.age %> | <%= link_to_remote( "Update", :update => "result", :url => {:action => 'update',:id=>(h sch.id)} ) %> | <%= link_to_remote( "Delete", :update => "result1", :url => { :action =>'delete',:id=>(h sch.id) } ) %> |
and student controller is…
class StudentController < ApplicationController
def index
end
def add
if request.post?
@school=School.new(params[:school])
if @school.save
@schools = School.find(:all)
render :partial =>'students'
else
render :partial =>'nonstudents'
end
end
end
def update
@school=School.find(params[:id])
@school.update_attributes(params[:school])
end
def delete
School.find(params[:id]).destroy
end
end
plz help…how I MANAGE THE DISPlay