Skip to content

Commit 037ce20

Browse files
committed
Added validation on PostUser, to only allow a user to have a post once
1 parent 1d8df4c commit 037ce20

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

app/models/post_user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ class PostUser < ActiveRecord::Base
44
belongs_to :user
55

66
validates :user_id, :post_id, presence: true
7+
validates :user_id, uniqueness: { scope: :post_id }
78
end

0 commit comments

Comments
 (0)