rails 多态关联 事务是这么处理的?
例如
[code="ruby"]
@attach = Attach.new(params[:attach])
@cook = Cook.new(params[:cook].merge({:user_id=>cookies[:user_id]}))
@attach.entry = @cook
@cook.save && @attach.save
[/code]
如果Attach验证失败 Cook则保存一条记录
如果Cook验证失败 Attach则保存一条记录
这么能把Attach和Cook 方进同一个事务