LoginSignup
1
1

More than 5 years have passed since last update.

Rails4.0 -> 4.1 で 出会った修正

Posted at

基本は下記を見る。

以下の <<を使った親子関係の子を挿入してsave!したところでnull例外。parent_children.parent_idがnullと言う。

rb
child = FactoryGirl.create(:child)
parent.child << child
stage.save!

下記のように命じする事で回避。

rb
child = FactoryGirl.build(:child)
parent.parent_children.build(parent:parent, child: child)
stage.save!

本当の原因を探っていないがこういうことがあった記録を取っておく。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1