diff options
author | Santosh Wadghule <santosh.wadghule@gmail.com> | 2018-05-22 19:04:24 +0530 |
---|---|---|
committer | Santosh Wadghule <santosh.wadghule@gmail.com> | 2018-05-28 18:23:21 +0530 |
commit | d7a3f33dbd4726480fcbefc0c3c1270396f61fd2 (patch) | |
tree | c7fef63458aafa3893a8819ab3c918a0f6bc64b1 /activerecord/test/models/reply.rb | |
parent | 2f76256127d35cfbfaadf162e4d8be2d0af4e453 (diff) | |
download | rails-d7a3f33dbd4726480fcbefc0c3c1270396f61fd2.tar.gz rails-d7a3f33dbd4726480fcbefc0c3c1270396f61fd2.tar.bz2 rails-d7a3f33dbd4726480fcbefc0c3c1270396f61fd2.zip |
Fix parent record should not get saved with duplicate children records
- Fixes #32940
Diffstat (limited to 'activerecord/test/models/reply.rb')
-rw-r--r-- | activerecord/test/models/reply.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index bc829ec67f..312c8677c2 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -16,6 +16,11 @@ end class SillyUniqueReply < UniqueReply end +class ValidateUniqueContentReply < Reply + belongs_to :topic, foreign_key: "parent_id" + validates :content, uniqueness: true +end + class WrongReply < Reply validate :errors_on_empty_content validate :title_is_wrong_create, on: :create |