You can clone with
Line 141 of finder.rb has this:
count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s]+$/mi, ''
If original query has an aliased table name, the ORDER BY is not stripped. For example,
SELECT * from authors a, books b WHERE b.author_id = a.id ORDER BY a.id DESC
If you modify the statement to be:
count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s\.]+$/mi, ''
the ORDER BY is stripped
I've submitted a pull request #148 for this issue.
Active Record: fix stripping ORDER clause in paginate_by_sql