XanderCheung
热度 5697 评论 0 赞 0
rails 5版本中
@user = User.new @user.students.build
@user = User.new
@user.students.build
save的时候就会保存不成功,那么在student.rb中的关联,加上optional: true
optional: true
belongs_to :user, optional: true