Rails order by association field
Merge can make the query smaller/saner-looking, and it benchmarked faster for me in Rails 4.x:
@users = User.joins(:user_extension).merge(UserExtension.order(company: :desc))
Try this:
@users = User.includes(:user_extension).order("user_extensions.company desc")
I think you need at order
: user_extensions
, not user_extension