Forum: Nitro Og and 'duck typing' search

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
62711fa2787e85b5f0c88e245ef69f54?d=identicon&s=25 Alexey Petrushin (axyd80)
on 2008-06-06 01:28
Can Og search for 'name' in all 'managed' classes?

I.e. there are: Post, User, Topic, Comment, ..., and all of them have
the 'name' property. So, can i use something like:

        Og.search_by_name('my_name')?

Or i should explicitly do it for all classes? I.e.:

        Post.search_by_name('my_name').
        concat(User.search_by_name('my_name')).
        concat ...
7a4e995e378ef66de0ceaea5e1381ee1?d=identicon&s=25 George Moschovitis (Guest)
on 2008-06-06 10:14
(Received via mailing list)
No you should do it for all classes:

User.find_by_name(name)
Post.find_by_name(name)

etc...

-g.

On Fri, Jun 6, 2008 at 2:28 AM, Alexey Petrushin <lists@ruby-forum.com>
Bd10252dc68b39171cc9bf5f74bcb9f1?d=identicon&s=25 Arne Brasseur (Guest)
on 2008-06-07 11:39
(Received via mailing list)
You should be able to do something like

Og.managed_classes.map {|c| c.find_by_name(name)}.flatten

A.
This topic is locked and can not be replied to.