ActiveRecord new_record?

ActiveRecord の new_record?

まだ save されていない record だったら true を返す。

違っていれば false。

厳密には、一つのレコードに対するオブジェクトが ストア(保存) されていなければ true

違えば false

https://github.com/rails/rails/blob/260471a5e1b00136fc2d6e66bab29059fc6d8174/activerecord/lib/active_record/persistence.rb#L66

別件だけど、読みやすい英語コメントだった。見習いたい。

    # Returns true if this object hasn't been saved yet -- that is, a record
    # for the object doesn't exist in the data store yet; otherwise, returns false.
    def new_record?
      sync_with_transaction_state
      @new_record
    end