Find_by_sql help on site search


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 and 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

@search_b = search_terms.compact.join(" OR LIKE “)
@search_v = search_terms.compact.join(” OR LIKE ")
@results = Video.find_by_sql([“SELECT, FROM bands b,
videos v WHERE = v.band_id AND LIKE ? OR LIKE ?”,
@search_v , @search_b])

RoR is my first language, so if my code seems inefficient, please don’t
be too harsh. :wink: I’m just trying to find a way to make it work.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs