I have a join table with this setup:
create_table "showable_videos", :force => true do |t|
t.integer "user_id"
t.integer "profile_id"
t.integer "video_id"
t.datetime "created_at"
t.datetime "updated_at"
end
How do开发者_如何转开发 I validate the uniqueness of a showable_video
? In other words, I need to make sure no two showable_videos
have all the same user_id
, profile_id
, and video_id
.
Try having a model ShowableVideo and put there:
validates_uniqueness_of :user_id, :scope => [:profile_id, :video_id]
精彩评论