Saturday, June 16, 2012

[Rails] searching on model and related attributes

Hi all,

Haven't played with rails for a while so I'm a little stuck. I've got to
make a search functionality across models.

Let me try to explain this (sorry for lack of clarity, I've been reading
so many search gems etc that I'm a little fuzzy now):

* Stores have town and county fields
* Stores has_many Products which each have their own name and level

Users need to be able to find all Stores (possibily limited by town or
county) which have one or more Products identified by name AND a minimum
level.

So I might search for Stores which have the Product 'Small Wooden Table'
with a level of at least 4 AND have the Product 'Oak Table' at least
level 10. Then I might restrict that to Stores in the county of
'Yorkshire'.

The list of Products is pretty long (300+) and I don't think it would be
user friendly to put them in a long drop-down list, so I'm tempted to
let users type in the name and level manually. If they don't type the
name correctly, then I guess they won't get the right results.

I've looked at several gems (including searchlogic and ransack) but none
seem to give me the ability to search related models in this way. I
might have to knock together something from scratch but I don't want to
end up being hideously inefficient.

Grateful for any pointers on this, and please let me know if I haven't
explained it well enough.

Many thanks

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate