Just started learning active record and am wondering how to best retrieve data from multiple tables where an SQL aggregate query is involved.
In the following example (f
In the current version of AR (2.3) I think your only option is to use find_by_sql. Why? Your custom SELECT attributes. ActiveRecord allows :select and :include arguments to the find call. Unfortunately they can't be used together. If you specify both the :select will be ignored. In your example you need the select to limit your columns and to get your MAX function.
I've heard there is a patch/hack to get them to work together, but I am not sure where it is.
Peer