I am printing id of the record in after save callback method as shown below. after printing the "id" i am raising the exception.
def after_save_run
puts "id is #{self.id}"
raise "exception"
end
Above method is generating below output for every save call
id is 1
id is 2
id is 3
Due to the exception in the after save method no records are saving in the database and hence my table is empty but then How acitverecord auto increments the primary key? How does activerecord knows what was the last generated id if there are no records in table?