开发者

creating models with multiple references in rails

开发者 https://www.devze.com 2023-01-10 04:59 出处:网络
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 an

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

精彩评论

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

关注公众号