I want to perform :group and :order on my module, since Mysql does group by before order by you get mixed results and not what you expected.
the SQL solution for that would be:
SELECT * FROM
(
select * from `my_table` order by timestamp desc
) as my_table_tmp
group by catid
order by nid desc
how can I write that in ruby using activerecord?
I think you can just use the Arel methods directly: