From: Shai Rosenfeld Date: 2007-09-09T18:03:37+09:00 Subject: Re: deleting an item with ajax John Griffiths wrote: > hi again, I managed to work out how to create a new item via ajax and > the form_remote_tag, however don't know how to delete an item from the > table. > > here's the code so far, doesn't work, keeps on popping up saying null.id > > > > > _item_list.rhtml > > <% for item in @list.items %> > .... > <% end %> > > def destroy_item > Item.find(params[:id]).destroy > render :partial=>'list' > end > found (e.g. it doesn't know which item to destroy). ..no, the item was destroyed, but when it tried rendering the partial again (via ajax Update) there was no item defined, as yo didn't add a @list variable, therefore there is no item in the loop, when it is rendered secondly. add a @list variable to the destroy_item action and u should be ok. btw, better to post on the ruby on rails forum (forum#3 rather than forum#4) -- Posted via http://www.ruby-forum.com/.