我有 3 个类,Schema、Entity 和 Property,代表 DB 设计业务。Schema-Entity 似乎有效,但 Entity-Property 无效。
class Hx::Entity < ActiveRecord::Base
belongs_to :schema
attr_accessible :name
has_many :properties , class_name: "Hx::Property" , primary_key: "id"
end
class Hx::Property < ActiveRecord::Base
attr_accessible :destination, :indexed, :inverse, :isToMany, :kind, :name, :optional, :transient , :type
belongs_to :entity
end
当我运行 entity_obj.properties 时,它会抛出错误undefined method primary_key' for String:Class
。
我扭曲了 has_many 的选项,但它没有帮助。
有人对此有任何想法吗?
谢谢。