0

I have a problem I cannot diagnose. I have an after_save callback in one of my models that correctly fires the callback and correctly creates/saves the model to the DB, but when I interrogate the values in 'self' (to perform some other action with the values I have ommited here due to NDA) the model appears as being empty.

Example:

after_save :automatically_map

private

def automatically_map
  put self.id
end

The callback correctly fires when I create or save a model, however self.id is 'nil' - and all the other attributes have defaulted to their blank/new object values.

Am I missing something obvious?

Ash
  • 24,276
  • 34
  • 107
  • 152

1 Answers1

1

Maybe, it's happened because db did not commited transaction. You can try to use

after_commit :automatically_map, on: :create