我有这些模特:
class Feed
include Mongoid::Document
field :name
field :host
field :user_name
...
has_many :stores
end
class Store
include Mongoid::Document
field :name
field :store_id
field :dealfeeds, type: Array
...
belongs_to :feed
end
但是当我尝试通过Feed添加商店时,我收到了以下错误:
>> Feed.stores << Store.new
NoMethodError: undefined method `stores' for Feed:Class
>> Feed[:stores] << Store.new
NoMethodError: undefined method `[]' for Feed:Class
答案 0 :(得分:1)