Alexandru E. Ungur
1/25/2007 5:53:00 PM
Hi all,
I appologise if this question is offtopic, hopefully it isn't though...
I have:
Forum has_many :comments
so obviously, I access the comments collection as
some_forum.comments
check its type with:
some_forum.comments.class # => Array
ok, that I expected, so I want to use Array#find on it, right?
some_forum.comments.find {...}
but oops, I get:
ActiveRecord::RecordNotFound: Couldn't find Comment without an ID
Hmm, that find is not the find I expected to find ;-) Looks like
an AR#find to me... but on an Array? It's not like I need SQL to
find certain elements of an Array... so I find this behaviour very
interesting. Am I doing something wrong here ? I can find the
element(s) I want from it, by iterating over it and selecting them,
but not by using find.
BTW, it's Rails 1.1.6/AR 1.14.4 I'm having this behaviour on, haven't
tested it on other versions.
Thank you in advance,
Alex