Closed rkumar closed 1 year ago
The where clause needs to refer to the actual table name rather than the association, so it should be pluralized:
collection.joins(:author).where("authors.name ILIKE ?", "%#{query}%")
Thanks. Worked perfectly.
I have a book/post table with author_id linking to author table (belongs_to :author). I am trying to add the author's name in the search but I keep getting errors because it seems that the author table is not getting linked in the query.
I've tried to add the authors table as follows:
I've also tried to add in the author in the search query:
However I keep getting errors such as:
How can I perform a search on a linked table ?