closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

Unknown primary key for table page_hierarchies in model PageHierarchy

Open mcmegavolt opened this issue 7 years ago • 7 comments

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

mcmegavolt avatar Dec 27 '17 23:12 mcmegavolt

+1

hirokishirai avatar Jun 03 '18 04:06 hirokishirai

+1

mmorast avatar Jun 04 '18 02:06 mmorast

+1

tomlockwood avatar Jul 09 '18 07:07 tomlockwood

+1

danthecrane avatar Jul 11 '18 14:07 danthecrane

Try: rails g migration AddPrimaryKeyToPageHierarchies id:primary_key rails db:migrate This helped to me

aykc avatar Jul 21 '18 18:07 aykc

Will this PK added cause any issues?

mmitchellg5 avatar Jun 30 '22 22:06 mmitchellg5

probably not, it's just a regular primary key field

aykc avatar Jul 01 '22 08:07 aykc