Forum: Ruby on Rails Dynamically updating list

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9e501a3637249870caa484c751a45995?d=identicon&s=25 parikshit (Guest)
on 2006-04-12 11:20
(Received via mailing list)
hi every body. i am try to do example of agil books.dynamically updating
list of chapter 18.
1)this is my code for controller----
class ListnoajaxController < ApplicationController
def index
@items = Item.find_recent
end
def add_item
item = Item.new(params[:item_body])
render(:partial => "item", :object => item)
end
def item
end
end
2)the code for item class in app/model
class Item < ActiveRecord::Base
attr_reader :body
attr_reader :posted_on
FAKE_DATABASE = []
def initialize(body)
@body = body
@posted_on = Time.now
FAKE_DATABASE.unshift(self)
end
def self.find_recent
FAKE_DATABASE
end
# Populate initial items
new("Feed cat")
new("Wash car")
new("Sell start-up to Google")
end
3)now i make two template
1)index.rhtml
2)_item.rhtml
and the template code of index.rhtml is




My To Do List





*******************************
the code for partial template _item.rhtml is

function item_added() {
var item = $('items').firstChild;
new Effect.Highlight(item);
Element.hide('busy');
$('form-submit-button').disabled = false;
$('item-body-field').value = '';
Field.focus('item-body-field');
}
function item_loading() {
$('form-submit-button').disabled = true;
Element.show('busy');
}


 'item', :collection => @items) %>

 { :action => "add_item" },
:update => "items",
:position => :top,
:loading => 'item_loading()',
:complete => 'item_added()') %>
 'item-body-field') %>
 'form-submit-button') %>
Adding...



****************************  *******************************
now i am refercing my page
http://127.0.0.1:3000/listnoajax/index
but it shows blank page
so plese any body tell me how i do that example.
thanx in advance
This topic is locked and can not be replied to.