1: 在config/application.rb设置 config.active_record.belongs_to_required_by_default = false
2: belongs_to 的时候添加optional: true
rails5 belongs_to 默认不能为空,报错must exist
猜你喜欢
转载自zhangcaiyanbeyond.iteye.com/blog/2371728
今日推荐
周排行