Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Luis Pablo's Profile

GitHub User: lgallo

Comments by Luis Pablo

Avatar

jayeshmori, Ben,

My way to solve that issue:

Use the column name with a table alias, for example: 'us.name'.
In the controller, always retrieve info joining the other table, with its alias 'Product.joins('JOIN table alias ON field = field')'

And then use as the column name, the alias + the column name, as I stated before.

And remember to include this 'special' name in the valid column names in the sort_column private method.

Hope it helps!