Hello,
Thanks for taking a look and offering up your help!
I''m trying to set up a way my site visitor can search my site via
band.name and videos.name simultaneously, for up to 10 results.  The
names should be searched for any and all keywords entered.   I think
I''m
close, but my query doesn''t return any results for me, but I''m
not
getting any errors.
Important Associations:  band has_many videos while videos belongs_to
bands.
@search_b = search_terms.compact.join(" OR b.name LIKE ")
@search_v = search_terms.compact.join(" OR v.name LIKE ")
@results = Video.find_by_sql(["SELECT b.name, v.name FROM bands b,
videos v WHERE b.id = v.band_id AND v.name LIKE ? OR b.name LIKE ?",
@search_v , @search_b])
RoR is my first language, so if my code seems inefficient, please don''t
be too harsh. ;) I''m just trying to find a way to make it work.
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-/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
-~----------~----~----~----~------~----~------~--~---