Lee Smith
2011-Feb-28 18:19 UTC
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 the error to my model inside of a method called from a ''before_add'' association callback (see prevent_user_from_having_more_than_one). From what I understand about Association Callbacks, you raise an exception so that you 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 than 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 the 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. https://gist.github.com/847748 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.