I have a bug where in a associated model, the parent model’s foreign key is coming as NULL in the associated model’s table.
To track down why this is happening, I would like to write to the log file each time an attribute is assigned-to (i.e. every call made to attr= methods).
How can I do this? Does Rails already allow this to be done via some way that I do not know of?
You can do it by simply overwriting the attr= method. For example:
You can also accomplish this by chaining methods. For example: