Skip to content

Tag: ruby-on-rails

Append additional conditions to a query

I have a query where I need to add several conditions as an OR clause, because I want to use LIKE, so I can not use IN instead. So how can I add multiple OR from an array? The SQL should look like this: where ‘a’, ‘b’, ‘c’ is from an array. Answer From the Rails API docs, t…

ActiveRecord having count query condition

I have 2 models : Conversation and Message I need to retrieve all conversations that belongs to a Brand and where there are at least one message from the brand and one message from an influencer This is my query : But i get conversations that doesn’t have messages from both… What am i doing wrong …