On 7 December 2015 at 13:55, fugee ohu <fugee...@gmail.com> wrote: > when the search gets submitted it only returns results for records that had > the searched value in publicists > > from my model: > def self.search(search) > where("headline LIKE ?", "%#{search}%") > where("storyline LIKE ?", "%#{search}%") > where("publicist LIKE ?", "%#{search}%") > end
The where method returns a set of matching records, your method runs the first where() and throws the result away, then it does the same with the second and throws the result away, then it runs the third and returns that. You presumably wish to find records where any of three are true so you need to use something like where(("headline LIKE ? OR storyline LIKE ? OR publicist LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%") Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuYdUJJQzNdCCohj4aiq4yS4ci_6F9xvmSkmFKy9QVvvw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.