category = Category.new
This isn't persi开发者_运维百科sted to DB yet, so how to distinguish form an object that is saved in the database?
c.persisted? # => true if persisted
c.new_record? # => true if not persisted
:)
c.new_record? # true if new, false if saved
精彩评论