0
创建一个对象。如果我有关联的has_many用户和物品模型:文章和belongs_to的:用户,我会写user.articles.new创建一个新的文章对象与正确的USER_ID。
所以我的问题是关于有许多模型belongs_to的关系:
几个协会
class Ownership < ActiveRecord::Base
attr_accessible :right_read, :right_create, :right_update, :right_delete
belongs_to :element
belongs_to :user
belongs_to :ownership_type
end
有没有一种解决方案来创建用3个ID的对象所有权完成(element_id,USER_ID,ownership_type_id)?
在“attr_accessible”中写这个ID是否危险? 谢谢。