[英]new! and create! in Ruby on Rails
Please anyone tell me why we use new!
请任何人告诉我为什么我们使用new!
or create!
或create!
in rails controller? 在导轨控制器?
Example==> 实施例==>
def new
new! do |format|
format.html {
set_group_and_class_autocomplete_data_sources(@node)
}
end
end
def create
create! do |success, failure|
failure.html {
set_group_and_class_autocomplete_data_sources(@node)
render :new
}
end
end
The create!, update_attributes! 创建!,update_attributes! are methods that raises exceptions if the record is invalid. 是在记录无效的情况下引发异常的方法。
Check this out: 看一下这个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.