Postgresql – How to convert ActiveRecord::Base.connection.execute collection ids (has_many) as an array instead of a string
This is my query within my controller (index action): @tags = ActiveRecord::Base.connection.execute( <<~SQL SELECT t.id, t.name, t.member_tags_count, ( SELECT json_agg(mt.member_id) as member_ids FROM member_tags mt WHERE mt.tag_id = t.id) FROM tags t ORDER BY LOWER(t.name) SQL ) render json: @tags…