Displaying 1 result from an estimated 1 matches for "fake_database".
2006 Apr 12
1
Dynamically updating list
...ionController
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)_it...