I am a bit stuck with the following problem, and would welcome
suggestions.
I have two tables, e.g. "things" and "properties", with one
line of of
things corresponding to one line of properties, and vice-versa, and 70
elements per line of properties. Users want to be able to find all
things where their favourite elements in the properties table are not
null, and the number of things they are interested in is variable. I
have put the list of elements on a page where users may select those
they are interested in and this returns a hash containing only those
they have selected, with values set to 1.
The only method I can come up with is to construct a string along the
lines of:
"select thing_id from properties where A is not null and B is not null
and C is not null..."
...etc., then use this with Property.find_by_sql. Then, I''d have to use
the output of that to do another search on things.
Is there any better way to do this with find? E.g something like:
@things = thing.find(:All, :conditions=>["properties.? is not
null",
array_of_interesting_elements], :include => :property)
This doesn''t work, of course, but perhaps there is something similar
that might?
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---