![Ruby On Rails](http://www.rubyonrails.org/images/rails.png) |
Rails has very nice features to validate a model (directly mapped on your database). However it gets sometimes sloppy if you don't know the exact command to do your validation.Here's a trick I had a hard time to find. |
Everybody knows how to validate the uniqueness of a field in a database :
validates_uniqueness_of :date
If you now want to validate the uniqueness of a couple (ex: date,user_id) here's how you can:
validates_uniqueness_of :date, :scope => :user_id