Alan F. wrote:
First off, is the callback being triggered at all ? If you replace the
whole body with the raise, do you see the exception ?
yes. I can catch the exception in the controller and display the
# attempt to add item to list
# extract error messages from the global variable
# representing the Exception object
flash[:notice] = $!.message
Second, if you just replace the body with the errors.add, do you see the
no, and the object that should not have been saved is saved.
Last, == on Object tests for the exact same Object, I think ActiveRecord
override this to compare ids, if the new item hasn’t yet been saved, the
== method will return false. Perhaps you need to check, say
keyword.text, or whatever the property is that stores the text.
I see your point. In my case the callback is before adding an existing
item to a collection that is defined as a self-referential