How to know whether a model is new or not? How to know whether a model is new or not? ruby ruby

How to know whether a model is new or not?


ActiveRecord's new_record? method returns true if the object hasn't been saved yet.


you can use post.persisted? as well, if it return false means record in new

persisted?