search for: item_find

Displaying 1 result from an estimated 1 matches for "item_find".

Did you mean: item_end
2006 Jan 04
0
Doesn''t "find" call initialize?
class Item < ActiveRecord::Base def initialize(*args) super @x = 5 end def print_x puts @x end end item_new = Item.new item_new.print_x # output: 5 item_find = Item.find(1) # this record is in the database item_find.print_x # output: nil I thought the output would be 5 in both cases, since Item.find returns a new object of Item and so Item.initialize would be called -- Posted via http://www.ruby-forum.com/.