2010-10-29 50 views

回答

31
c.persisted? # => true if persisted 
c.new_record? # => true if not persisted 

:)

+0

+1,我沒有注意到的'堅持?'的存在! – PeterWong 2010-10-29 08:51:55

+0

值得一提的是'持久性?'直到Rails 3.0才被定義http://apidock.com/rails/ActiveRecord/Persistence/persisted%3F – 2015-04-30 15:14:27

3
c.new_record? # true if new, false if saved 
相關問題