Skip to content

Commit 796f8c5

Browse files
committed
Fix bug with inheritance and primary_key
1 parent bef8535 commit 796f8c5

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

lib/active_admin/mongoid/document.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,12 @@ def quote_column_name name
2727
end
2828
end
2929

30-
# CLASS METHODS
31-
3230
included do
33-
unless respond_to? :primary_key
34-
class << self
35-
attr_accessor :primary_key
36-
end
31+
unless respond_to?(:primary_key) && respond_to?(:primary_key=)
32+
class_attribute :primary_key, instance_writer: false
3733
end
3834

39-
self.primary_key ||= :id
35+
self.primary_key = :id if primary_key.nil?
4036

4137
def column_for_attribute(name)
4238
self.class.fields[name.to_sym]

0 commit comments

Comments
 (0)