Hi there,
i wrote an intelligent searchform, which is divided into categories.
Just a short overview of the workflow. For every keyword, which is
entered in the searchform the matches are checked. So we''ve got a rank
in a hash.
[key of entry, relevance match]
For example:
@hash = [123 => 5, 124 =>2, 125 => 5, 126 => 1, etc...]
I ordered the Hash "by relevance" simply by ordering by the hash
values:
@hash.sort_by {|a,b| b})
@hash = [123 => 5, 125 => 5, 124 =>2, 126 => 1, etc...]
No I want to find my entries by the key values of the hash.
Thats not the problem:
@entries = Entry.find(@hash)
or
@entries = Entry.find(@hash.keys)
The problem is, that the entries are (by standard) ordered by ID and not
in order by the Hash-Keys I passed.
Is there a possibility to order by my "relevance system" (even if
there
isn''t a coloumn in the Entries-Table.
Thank you ''till now
Hans
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.