Override << method


#1

Ok, this statement may prove that i am designing my app incorrectly
but I have several HABTM relationships in my application that I add to
using the <<. However, this undermines my ability to validate
uniqueness of my rows. As an example.

a = Article.find(1)

c = Comment.find(1)

a.comments << c
a.comments << c

a.comments.size
“2”

Obviously, I’d like to avoid this. Even though I have locked down the
presentaion layer so that theoretically this sort of thing would not
happen, I’d like to protect it on the model layer if possibe.

Any Ruby syntax gurus out there feel free to chime in, I am all ears.

Thanks!

Mark