Determine Whether an ActiveRecord Object is a New Record or Not
This short blog post will show you how to determine if an ActiveRecord object is new or not.
Published on:October 4, 2013
new_record?
method. For example:
book = Books.where(isbn: "0374180660").first_or_initialize
if book.new_record? # => true if book is new, false if it wasn't.
# Perform misc stuff here.
end