Forum: Ruby on Rails paginator order_by

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D1b95bbed05fba1ac2e8af53cc536c10?d=identicon&s=25 Alan Curtis (pheon)
on 2007-05-25 18:52
I would like to use the paginator helper to order by a quantity that is
the product of two database columns.

Is there a simple way to do this?
B1edc6a4aa373d980b49e600923df552?d=identicon&s=25 Douglas Shearer (dougal)
on 2007-05-26 14:47
Alan Curtis wrote:
> I would like to use the paginator helper to order by a quantity that is
> the product of two database columns.
>
> Is there a simple way to do this?

Someone will correct me if I'm wrong, but by using simple SQL you should
be able to do...

:order => "(col1 * col2)"

I'm also assuming that by product you mean multiplication. You can of
course do any simple maths, or even other SQL queries in here.
This topic is locked and can not be replied to.