@content.keys.build works even when @content.keys is empty array. how?

my models: content has_many keys
I don’t understand how is it possible that empty array will have
‘build’ method?

@content = Content.create(:text => ‘test’)
=> #<Content id: 3, text: “test”, created_at: “2010-04-28 19:04:19”,
updated_at: “2010-04-28 19:04:19”>

@content.keys
=> []

but this works. can someone explain how can it be?
@content.keys.build
=> #<Key id: nil, name: nil, content_id: 3, created_at: nil,
updated_at: nil>

Thanks

On Apr 28, 8:09 pm, oren [email protected] wrote:

my models: content has_many keys
I don’t understand how is it possible that empty array will have
‘build’ method?

Because it’s not actually an array - it’s an association proxy.

Fred

got it.
too bad .class don’t shows me Array…

On Apr 28, 9:16 pm, Frederick C. [email protected]