简体   繁体   中英

new! and create! in Ruby on Rails

Please anyone tell me why we use new! or 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! are methods that raises exceptions if the record is invalid.

Check this out:

Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM