RailsAdmin not figuring out composite key
I have a table in postgres with a composite key. I am trying to access it using rails_admin.
class ModelName < ActiveRecord::Base self.table_name = 'schema.tablename' establish_connection :db end
I can see the count of rows and the table name and everything. But when I click on the table in the admin UI, it fails with this error
: SELECT "schema"."tablename".* FROM "schema"."tablename" ORDER BY schema.tablename. desc LIMIT 20 OFFSET 0
The id is missing in the order by clause. Is this because it is a composite id? How do I get rails admin to properly identify the id of the table?作者: leoOrion 的来源 发布者: 2017 年 9 月 15 日
It was not a problem with
rails_admin but with ActiveRecord. ActiveRecord does not support composite keys. I had to install a gem called
composite_primary_keys and then define the composite key in the model. Rails Admin was then able to pick up the correct id and display the entries.