How can I check if an ActiveRecord
object is new or is already persisted?
Ruby-on-rails – Determine if ActiveRecord Object is New
activerecordruby-on-rails
Related Topic
- Ruby-on-rails – How to get the name of a Ruby class
- Ruby-on-rails – How to get the current absolute URL in Ruby on Rails
- Ruby-on-rails – How to get ActiveRecord to show the next id (last + 1) in Ruby on Rails
- Ruby-on-rails – ActiveRecord OR query
- Ruby-on-rails – How to delete an ActiveRecord object
- Ruby-on-rails – Float vs Decimal in ActiveRecord
- Ruby-on-rails – Converting an array of objects to ActiveRecord::Relation
- Ruby-on-rails – Rails 5: ActiveRecord OR query
Best Answer
An ActiveRecord object lifecycle:
1.new record
2.persisted
3.changed
4.destroyed