views:

8

answers:

2

e.g.

c=Category.new

this is didn't persistence to db, how to distinguish a object wheather persistenced to db yet

+1  A: 
c.persisted?  # => true if persisted
c.new_record? # => true if not persisted

:)

slainer68
+1, I didn't noticed the existence of `persisted?`!
PeterWong
A: 
c.new_record? # true if new, false if saved
PeterWong