You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a model with some scopes involving joins. For example:
class User < ActiveRecord::Base
...
def self.popular
joins('LEFT JOIN followings ON users.id = followings.followee_id').
group('users.id').
where('COUNT(users.id) > 10')
end
...
end
If I add this scope to my ActiveAdmin config, I get the following error when viewing the Users index:
Mysql2::Error: Column 'id' in order clause is ambiguous: SELECT COUNT(*) AS count_all, users.id AS users_id FROM `users` LEFT JOIN followings ON users.id = followings.followee_id GROUP BY users.id WHERE COUNT(users.id) > 10 ORDER BY id desc
This appears to be because in lib/active_admin.rb the default sort order is set to "id_desc", which doesn't then get scoped with the appropriate table name - hence the ambiguous query error.
There's a gist here with the full stack trace in case it's useful...
Cheers,
Simon
p.s. thanks for a wonderful tool, by the way - I'm really loving what I've seen of it so far.
The text was updated successfully, but these errors were encountered:
Hi,
I'm using a model with some scopes involving joins. For example:
If I add this scope to my ActiveAdmin config, I get the following error when viewing the Users index:
This appears to be because in
lib/active_admin.rb
the default sort order is set to "id_desc", which doesn't then get scoped with the appropriate table name - hence the ambiguous query error.There's a gist here with the full stack trace in case it's useful...
Cheers,
Simon
p.s. thanks for a wonderful tool, by the way - I'm really loving what I've seen of it so far.
The text was updated successfully, but these errors were encountered: