rails/rails — pull request #17964 by carols10cents (2014-12-08 03:42:22+00:00)
Title: Make error message clearer that :on requires a symbol, not a string

The validation added in 5a3dc8092d19c816b0b1203945639cb91d065847 will
reject values for the `:on` option for after_commit and after_rollback
callbacks that are string values like `"create"`.

However, the error message says ":on conditions for after_commit and
after_rollback callbacks have to be one of create,destroy,update". That
looks like a string value *would* be valid.

This commit changes the error message to say ":on conditions for
after_commit and after_rollback callbacks have to be one of [:create,
:destroy, :update]", making it clearer that symbols are required.

I discovered this in upgrading an app to rails 4 where we had an `after_commit` activerecord hook with the options `on: "create"`. Strings used to be vaild, but with the combination of PR #5100 adding the validation, PR #9356 removing the `.to_sym` call in the validation method, and then PR #11096 removing the `.to_sym` call in the actual use of the option value, strings are no longer valid.

I'm fine with requiring symbols here, as long as the error message makes that clear, which is what this pull request does. I'd also be happy to put back the `.to_sym` calls to allow strings again if yinz would rather.

I also didn't make a changelog entry since this is practically just documentation; let me know if I should add one and I will be happy to.