开发者

creating models with multiple references in rails

I have a model defined as

class A < ActiveRecord::Base
  belongs_to :b
  belongs_to :c
end

How do I create a new instance of A associated with both b and c.开发者_高级运维 I've got the ids for b and c.


You can create a new instance of a like this:

A.create :b => b, :c => c
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜