Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column order of results from rails ActiveRecord find_by_sql call

I'm attempting to put together some basic report screens. I've got some fairly complicated SQL queries that I'm feeding into ActiveRecord's find_by_sql method. The problem I am having here is that I am losing the order of the columns as given in the original query. I'm assuming that this is because the Hash class does not preserve entry order of its keys.

Is there a way around this problem? Should I be using a different method then find_by_sql for my queries?

like image 514
Jeff Waltzer Avatar asked Sep 21 '25 11:09

Jeff Waltzer


1 Answers

I like to use Ruport for reporting. It has good ActiveRecord integration and it enables you to control column order and pretty much anything else. And it's sufficiently simple to use that I don't consider it overkill even for "basic" reports.

like image 177
Avdi Avatar answered Sep 23 '25 01:09

Avdi