closure_tree
closure_tree copied to clipboard
Unknown primary key for table page_hierarchies in model PageHierarchy
I'm using rails 5.1.4 with activeadmin
When try to load pages index in ActiveAdmin got the error
Showing /home/ap/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activeadmin-1.2.0/app/views/active_admin/resource/index.html.arb where line #2 raised:
Unknown primary key for table page_hierarchies in model PageHierarchy.
def primary_key(klass)
klass.primary_key || raise(UnknownPrimaryKey.new(klass))
end
My page model
class Page < ApplicationRecord
...
has_closure_tree order: 'sort_order'
...
end
+1
+1
+1
+1
Try: rails g migration AddPrimaryKeyToPageHierarchies id:primary_key rails db:migrate This helped to me
Will this PK added cause any issues?
probably not, it's just a regular primary key field