我正在尝试使用 mongoid_commentable 向我的文档添加评论。一切正常,唯一的问题是在 rails-admin (gem) 我收到错误“undefined method `rails_admin_default_object_label_method' for #”。根据其他在线讨论,此错误与模型之间的关系有关。
我的模型如下,我无法弄清楚我做错了什么?
评论模型
class Comment
include Mongoid::Document
include Mongoid_Commentable::Comment
field :text, :type => String
field :user_id, :type => String
embedded_in :document, class_name: 'Document', inverse_of: 'comments_list'
belongs_to :user, :class_name => "User", inverse_of: 'comments_list'
end
文档模型
class Document
include Mongoid::Document
include Mongoid_Commentable::Comment
...
embeds_many :comments, class_name: 'Comment', inverse_of: 'comments_list'
accepts_nested_attributes_for :comments
end
用户模型
class User
include Mongoid::Document
include Mongoid_Commentable::Comment
...
has_many :comments, class_name: 'Comment', inverse_of: 'comments_list', :dependent => :destroy
accepts_nested_attributes_for :comments
end
- 编辑 -
我相信这个问题可能与 mongoids“embeds_many”有关 - 请参阅此处了解更多信息:https ://github.com/sferik/rails_admin/issues/1547
环境信息:
导轨:3.2.12 Mongoid:3.1.4