[Nitro] Dynamic finders having initializer, but collections have none
Aleksi Niemela
Aleksi.Niemela at cs.helsinki.fi
Wed Nov 23 15:21:33 EST 2005
I wrote a patch to allow dynamic finder creators to have initializator
as a block. So code could look like:
u = User.find_or_create_by_name('tim') {|t| t.age = 13 }
But that didn't solve my problems yet. I'd like to see two improvements
(was unable to provide patch for those right away).
1) Collections don't have any dynamic finders. It's not possible to write
user.tags.find_by_name_and_status('foo', 'in use')
So this marvellous feature should be brought into collections as well!
2) Collections don't have dynamic finder creators. With new patch one
can't still write
Tags.find_or_create_by_user_oid_and_name_and_status(user.oid, 'foo',
'in use') do |t|
user.tags.add_tag t
end
or perhaps this works but nothing more complicated probably not, as in
the block the object isn't properly initialized yet.
I have to say I really like how Og is introducing nice features!
- Aleksi
More information about the Nitro-general
mailing list