【发布时间】:2017-02-27 09:30:06
【问题描述】:
我正在使用 Rails 5、Rails Admin 和 MongoId,在我的模型中,我添加了
has_and_belongs_to_many :topics, class_name: 'Topic', :foreign_key => :topicIds
它适用于“编辑页面”,但当我尝试更改 topicIds 的值时不起作用
message: Attempted to set a value for 'topic_ids' which is not allowed on the model AppUser. summary: Without including Mongoid::Attributes::Dynamic in your model and the attribute does not already exist in the attributes hash, attempting to call AppUser#topic_ids= for it is not allowed. This is also triggered by passing the attribute to any method that accepts an attributes hash, and is raised instead of getting a NoMethodError. resolution: You can include Mongoid::Attributes::Dynamic if you expect to be writing values for undefined fields often.
表示 MongoId 不完全理解 ':foreign_key'。你有什么解决办法吗?
【问题讨论】:
标签: mongoid rails-admin