例えばLikeの実装で例えば1つの記事に対しては1ユーザー当たり1回しかLikeできないとします。 つまり、(article_id, user_id)の組み合わせはユニークでなくてはなりません。 そういったときのvalidationの書き方は以下のようにかなりシンプルに書くことができます。 class Like < ActiveRecord::Base belongs_to :user belongs_to :article validates :user_id, :uniqueness => {:scope => :article_id} end