2017-02-27 22 views
0

ich Rails bin mit 5, Rails Admin und MongoId, In meinem Modell, habe ichhas_and_belongs_to_many und foreign_key funktioniert nicht in Rails Admin + MongoID

has_and_belongs_to_many :topics, class_name: 'Topic', :foreign_key => :topicIds 

Es arbeitet mit 'Edit-Seite', aber nicht funktioniert wenn ich versuche, den Wert von 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. 

Es zu ändern bedeutet, dass MongoId nicht vollständig verstehen ‚: foreign_key‘. Hast du eine Idee, es zu reparieren?

Antwort

0

löste ich mein Problem durch ein Alias-Feld zum Modell hinzu:

field :topicIds, type: Array, :as => :topic_ids 
Verwandte Themen