【发布时间】:2012-11-15 13:16:07
【问题描述】:
我有一个问题 “has_and_belongs_to_many”和“accept_nested_attributes_for” 在制造和mongoid的上下文中
我有一个可以提供许多服务的位置
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* 的工作示例以及 mongoid 和制造 gem(它适用于 mongoid “开箱即用”吗?
有什么建议吗?
我正在使用 mongoid3
【问题讨论】:
标签: ruby-on-rails-3 mongoid3 fabrication-gem