我正在尝试使用mongoid_commentable向我的文档添加注释。一切正常,唯一的问题是在rails-admin (gem)中,我得到了错误“未定义的方法`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我相信这个问题可能与蒙古"embeds_many“有关--更多信息请参见:行政/问题/1547。
环境信息:
Rails: 3.2.12蒙古: 3.1.4
发布于 2013-08-06 10:58:11
我无法解决这个问题,所以我决定使用active admin代替。希望他们在Rails Admin的未来版本中解决这个问题。
查看这个github问题。
https://stackoverflow.com/questions/17858666
复制相似问题