Category/tag entry search

Frederick Ros sl33p3r at free.fr
Tue Jun 27 15:50:26 EDT 2006


Andre Nathan wrote :
| Hello
| 
| I'm using this code to search for the latest post of a given category in
| my blog:
| 
|  <% entry = weblog.find(:match => /^mycategory\//, :lastn => 1).first %>
| 
| Is there a better way to do that search? Maybe using tags? Ideally I'd
| like to filter based on a tag name instead of relying on doing a match
| that depends on the filesystem layout.

AFAIR, by default if you do not set the Hobix::Entry.no_implicit_tag to
true, each of your entry should have at least a tag named after its
category.

Thus, if you do something like:

  entry = weblog.find.find_all {|e| e.tag == "mycategory"}[0]

you should have something working (not tested though).

-- 
Frederick Ros aka Sleeper -- sleeper at jabber.fr

panic("Alas, I survived.\n");
        linux-2.6.6/arch/ppc64/kernel/rtas.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/hobix-is-the-way/attachments/20060627/d549ba0b/attachment.bin 


More information about the Hobix-is-the-way mailing list