合伙人将多个模型关联在一起并使它们表现为一个整体。像视图(验证、错误、表单端点)和控制器(restful操作)的单个模型一样嘎嘎作响。也是#accepts_nested_attributes_for的。您可能想查看以处理更复杂的情况。更新:Rails核心团队现在正在研究,我强烈建议使用它而不是这个。
用法:
# app/forms/guest_order
class GuestOrder
include Associates
associate :user
associate :order, only: :product, depends_on: :user
associate :payment, depends_on: :order
end
# app/models/user
class User < ActiveRecord::Base
暂无评论