Ruby on Rails Wednesday, April 28, 2010

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment