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
Currently, the list views still offer the option to sort by belongs_to associations(and maybe others?), even if the database adapter is non-relational (e.g. MongoID). RailsAdmin then raises a RuntimeError, which is not easy to handle, since it doesn't have a more specific error class to target.
The MongoID adapter does set adapter_supports_joins? to false, but as you can see in the code above, that doesn't cause sortable to return a falsey value, just a different kind of truthy value, so the view still offers to sort by that column. I'm not sure what the intention is, but it seems that sortable should return false for belongs_to associations on non-relational databases? Otherwise you get the sort link, and when you click on it, you end up here (the aforementioned RuntimeError): https://github.com/sferik/rails_admin/blob/5da7874fa606fd0a9627764482ff81833ef11921/lib/rails_admin/adapters/mongoid.rb#L193
The text was updated successfully, but these errors were encountered:
Currently, the list views still offer the option to sort by belongs_to associations(and maybe others?), even if the database adapter is non-relational (e.g. MongoID). RailsAdmin then raises a RuntimeError, which is not easy to handle, since it doesn't have a more specific error class to target.
It looks like there is some code to try to disallow sorting by association for non-relational databases in the view here:
https://github.com/sferik/rails_admin/blob/5da7874fa606fd0a9627764482ff81833ef11921/app/views/rails_admin/main/index.html.haml#L87
And that property is defined for a belongs_to association here:
https://github.com/sferik/rails_admin/blob/5da7874fa606fd0a9627764482ff81833ef11921/lib/rails_admin/config/fields/types/belongs_to_association.rb#L15
The MongoID adapter does set
adapter_supports_joins?
to false, but as you can see in the code above, that doesn't cause sortable to return a falsey value, just a different kind of truthy value, so the view still offers to sort by that column. I'm not sure what the intention is, but it seems thatsortable
should return false for belongs_to associations on non-relational databases? Otherwise you get the sort link, and when you click on it, you end up here (the aforementioned RuntimeError):https://github.com/sferik/rails_admin/blob/5da7874fa606fd0a9627764482ff81833ef11921/lib/rails_admin/adapters/mongoid.rb#L193
The text was updated successfully, but these errors were encountered: