- belong_to 关联 强制校验
在rails5中config.active_record.belongs_to_required_by_default = true 通过设置该属性默认开启对belong_to 关联校验
可以在model 通过设置optional: true 取消校验
https://stackoverflow.com/questions/10462676/best-practice-about-empty-belongs-to-association
本文标题:rails 5的新特性
本文链接:https://www.haomeiwen.com/subject/hwgxsxtx.html
网友评论