So basically I'd like to know if there's some common approach to define own association types. Some details:

I have a model conversations that has a PG array column user_ids. So, to retrieve user conversations I need to run: select conversations.* from conversations where USER_ID = ANY(conversations.user_ids)

Since finder_sql and it's friends are deprecated now, I would really like to know what would be the best way to implement this pseudo has_many association?

currently I just use the methods like:

 def conversations
   Conversation.where("#{id} = ANY (conversations.users)")
 end

So basically I'm thinking of implementing my own ActiveRecord::Associations::CollectionAssociation and would like to know if there're some good references or if you could advice where to start at


Edit
Report