I need to do a complex SQL query that crosses several models and joins data; This is a sort of one-off adhoc report within my application, so I am not able to do this through standard model syntax.
I looked at ActiveRecord::Base.connection.select_rows, and this is very much what I want, but it returns a straight up array or arrays without including column names. Ideally I would like something that works in the same manner as select_rows, but returns some more information, along the lines of an array of dictionaries so that I can use key value lookups when building out my report page.
You can do this using
ActiveRecord::Base.connection.select_all().