Marnen Laibow-Koser wrote: >>> ... validates_associated is silly and circularity-prone. >>> You should be using foreign key constraints in the DB for this >> >> Well, I'll take that under advisement :-) but I would prefer to have the >> business logic in the app, and tested. > > Data integrity checking isn't business logic in the usual sense -- and > it really is the job of the database.
+1 I strongly agree with Marnen on this point. Data integrity (especially referential integrity) is the database's responsibility. As far as I'm concerned business logic should add value to your model. Adding integrity at the database level is safer, smarter and allows you to save unnecessary test code in your application. Any reasonable database should contain it's own test code for verifying it knows how to validate data integrity. > You're falling into the common Rails trap of not respecting the > database's intelligence. It's not dumb, and it should not be treated as > if it were. I have to say I don't always follow my own advice on this point. I catch myself not adding all the integrity constraints I really should have. but whenever the data is "important" there's no better way to ensure integrity than to do so in the database layer. -- Posted via http://www.ruby-forum.com/. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

