Querying any member of a Postgres array type in Rails 4 -


everywhere looked there 2 examples

either

book.where("'history' = (subjects)") 

to query book specific subject in subject array

or

 book.where("subjects @> ?", '{'history', 'drama'}') 

to query books subjects array has both history , drama

how query books has either history or drama or both?

at moment solving using

query = subject_list.map |subject|                 "'#{subject}' = any(subjects)"             end.join(" or ")  book.where(query) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -