在Ruby on Rails的,什么是创造,创造的区别!和API文档没有它? [英] In Ruby on Rails, what's the difference between create and create! and API docs doesn't have it?

查看:123
本文介绍了在Ruby on Rails的,什么是创造,创造的区别!和API文档没有它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ActiveRecord的有创建有的人用创造! ...这是不是创造!可以抛出一个异常,而创建不?我找不到创造!的 目前Rails的API文档...

ActiveRecord has create and some people use create!... Is it that create! can raise an exception while create doesn't? I can't find create! in the current Rails API docs...

推荐答案

创造!将提高对故障异常,创建刚刚返回false。文件位置:

Yes, create! will raise an exception on failure, create just returns false. Documentation here:

<一个href="http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-create-21">http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-create-21

这篇关于在Ruby on Rails的,什么是创造,创造的区别!和API文档没有它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆