{"action":"opened","issue":{"url":"https://api.github.com/repos/mynameisrufus/sorted-activerecord/issues/2","labels_url":"https://api.github.com/repos/mynameisrufus/sorted-activerecord/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/mynameisrufus/sorted-activerecord/issues/2/comments","events_url":"https://api.github.com/repos/mynameisrufus/sorted-activerecord/issues/2/events","html_url":"https://github.com/mynameisrufus/sorted-activerecord/issues/2","id":67147235,"number":2,"title":"It is impossible to sort by association's fields","user":{"login":"kirushik","id":152719,"avatar_url":"https://avatars.githubusercontent.com/u/152719?v=3","gravatar_id":"","url":"https://api.github.com/users/kirushik","html_url":"https://github.com/kirushik","followers_url":"https://api.github.com/users/kirushik/followers","following_url":"https://api.github.com/users/kirushik/following{/other_user}","gists_url":"https://api.github.com/users/kirushik/gists{/gist_id}","starred_url":"https://api.github.com/users/kirushik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirushik/subscriptions","organizations_url":"https://api.github.com/users/kirushik/orgs","repos_url":"https://api.github.com/users/kirushik/repos","events_url":"https://api.github.com/users/kirushik/events{/privacy}","received_events_url":"https://api.github.com/users/kirushik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-08T14:49:23Z","updated_at":"2015-04-08T14:49:23Z","closed_at":null,"body":"Let's say we have a Post class, which belongs to a User class.\r\n\r\nIn the sorted 1.0 it was possible to pass 'users.name' to `sorted` method on Post.references(:user).includes(:user), and have our users list sorted by an association name (quite handy in admin views, for example).\r\n\r\nNow `Post.references(:user).includes(:user).sorted(order: 'users.name ASC')` tries to sort with `ORDER BY \"posts\".\"users.name\" ASC`, which is not a desired (or even valid) query.\r\n\r\nDemo project: https://github.com/kirushik/sorted_misbehaves"}}