sort_by a calculation of two fields

3 views
Skip to first unread message

Paul Bowsher

unread,
Feb 12, 2009, 7:24:25 AM2/12/09
to ambition.rb
Hi,

I'd like to do the following:
.sort_by { |mirror| (mirror.connections_used -
mirror.connection_limit) }

which should generate "ORDER BY connections_used - connection_limit"

When I try the sort_by above, I get:

RuntimeError: [:connections_used, [:array, [:call,
[:dvar, :mirror], :connection_limit]]]

Does anyone know how to make this work?

Regards,

Matthew King

unread,
Feb 12, 2009, 4:12:41 PM2/12/09
to ambit...@googlegroups.com
The ambitious-activerecord adapter doesn't know how to handle
arithmetic operations yet.
Reply all
Reply to author
Forward
0 new messages