Doesn't "find" call initialize?

class Item < ActiveRecord::Base

def initialize(*args)
@x = 5


def print_x
puts @x

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs