Describe the bug
Any models that has a namespaced table name of the form self.table_name = 'my_schema.my_table' cannot be listed/sorted. Gives the follow error:
ActiveRecord::UnknownAttributeReference - Query method called with non-attribute argument(s): "my_schema.my_table.my_primary_key asc"
Reproduction steps
Create a model that has a namespaced table name (DBMS-dependent)
Ensure it is being loaded by rails_admin
Click on the model in the left nav to go to the list view.
Expected behavior
It should show the list view as normal, and further be able to sort.
Additional context
rails version: 6.1.7.3
rails_admin version: 3.1.2
rails_admin npm package version:
DBMS: Oracle 19c, using the adapter gem activerecord-oracle_enhanced-adapter-6.1.6
I am able to at least bring up the list view by adding the following model config:
RailsAdmin.config do |config|
config.model 'MyModel' do
list do
sort_by 'my_model.my_primary_key'
end
end
end
However, further sorting within the list view fails because it reverts back to trying to sort by using my_schema.my_table.column_to_sort.
Thoughts
I realize this ultimately boils down to an issue with rails (ActiveRecord::QueryMethods#reorder), but it would be nice if rails_admin could check the model's table name, and strip out the schema before listing/sorting.
Describe the bug Any models that has a namespaced table name of the form
self.table_name = 'my_schema.my_table'
cannot be listed/sorted. Gives the follow error:Reproduction steps
Expected behavior It should show the list view as normal, and further be able to sort.
Additional context
rails
version: 6.1.7.3rails_admin
version: 3.1.2rails_admin
npm package version:activerecord-oracle_enhanced-adapter-6.1.6
Workaround
I am able to at least bring up the list view by adding the following model config:
However, further sorting within the list view fails because it reverts back to trying to sort by using
my_schema.my_table.column_to_sort
.Thoughts
I realize this ultimately boils down to an issue with rails (ActiveRecord::QueryMethods#reorder), but it would be nice if rails_admin could check the model's table name, and strip out the schema before listing/sorting.