How do you display validation errors when using Association Callbacks?

I’m trying to get a validation error to appear on my form. I’m adding
error to my model inside of a method called from a ‘before_add’
callback (see prevent_user_from_having_more_than_one). From what I
understand about Association Callbacks, you raise an exception so that
trigger a database rollback so the invalid data is reversed out of the
database. And that works for me…it will not let me associate more
one group to a user with a role of ‘user’.

The problem is that I can’t get that error to show up in the view (on
form) even though I explicitly set the error on the model in that
:before_add method. So what am I doing wrong? Thanks for any help.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs