为了
has_*
我们有
no_assoc_constraint
. 当我们试图删除父级而子级仍然存在时,它工作正常并抛出一个变更集错误。有什么功能可以使用吗
many to many
.
就像这三种模式
schema "facilities" do
field(:name, :string)
field(:description, :string)
field(:is_active, :boolean, default: true)
many_to_many(:users, User, join_through: "users_facilities")
end
schema "users_facilities" do
belongs_to(:user, User, primary_key: true)
belongs_to(:facility, Facility, primary_key: true)
end
schema "users" do
field(:first_name, :string)
field(:last_name, :string)
field(:email_address, :string)
field(:username, :string)
many_to_many(:facilities, Facility, join_through:
"users_facilities")
当我试图删除一个设施时,其外键存在于用户设施中。我想得到变更集错误。