「has_and_belongs_to_many」と「accept_nested_attributes_for」について、製作とモンゴイドの文脈で質問があります
私は多くのサービスを持つことができる場所を持っています
class Location
include Mongoid::Document
field :name
field :service
has_and_belongs_to_many :services, inverse_of: :locations, autosave: true, dependent: :delete
accepts_nested_attributes_for :services
attr_accessible :services, :name
class Service
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :locations, inverse_of: :services, autosave: true
accepts_nested_attributes_for :locations
attr_accessible :name, :icon, :description
私の製作ファイルにはこれがあります
Fabricator(:service) do
initialize_with { Location.produce(:location) }
name "Service Name"
description "Lorem ipsum est lauda en radios"
location
end
Fabricator(:location) do
name "Special Club"
service
end
この場合、rspec がハングアップします。
誰かが*accept_nested_attributes*および/または*has_and_belongs_to_many*をモンゴイドとファブリケーションジェム(モンゴイドで「箱から出して」動作する)で動作する例を提供できますか?
助言がありますか?
私はmongoid3で作業しています