Override << method

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


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.



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