https://joe11051105.gitbooks.io/you-need-to-know-about-ruby-on-rails/content/activerecord/persisted_vs_new_record.html persisted? vs new_record? Explain ● persisted? 判斷是否已經存入 database 且不是新增的資料 ● new_record? 判斷是否是新增資料 Eaample user = User.new user.new_record? # true user.persisted? # false user = User.first user.new_record? # false user.persisted? # true
时间: 2024-10-11 14:09:39