我有两个模型attributeType
和person
。我想在数组中创建attributeType
类的实例,然后在person
类的实例中创建
attributeType (id, name)
person(name, attributeType)
实例如下:
instance of attributeType is => attribute (id, value)
instance of person is => pers (attribute, name)
请问如何创建所有内容?
我的person
模型:
class Person < ApplicationRecord
self.primary_key = "id"
has_many :attributeTypes , :through => :person_has_attributeTypes, dependent: :destroy
end
我的attributeType
模型:
class AttributeType < ApplicationRecord
has_many :persons, :through => :person_has_attributeType, dependent: :destroy
end