Using rails 4, I am using a custom SQL statement that I don't think I can relate to a Model specifically so I am thinking of using a RAW SQL:
sql = "select categ_a.processu_id,
categ_a.category_id as category_id_a,
categ_a.group_id as group_id_a,
categ_b.category_id as category_id_b,
categ_b.group_id as group_id_b
from
(select processu_id, category_id, group_id from categorizations where group_id = #{group_id_a})
categ_a INNER JOIN
(select processu_id, category_id, group_id from categorizations where group_id = #{group_id_b})
categ_b ON categ_a.processu_id = categ_b.processu_id"
processus_array = ActiveRecord::Base.connection.execute(sql, {:group_id_a => group_id_a, :group_id_b => group_id_b})
The table "categorisations" has - in this case - two entries for each processu_id one for each of the group_id.
My question really is about how to pass parameters to ActiveRecord::Base.connection.execute so that it will take the two group_ids. The statement above gives me an error.