Skip to content

Commit

Permalink
update comment examples to use validates format
Browse files Browse the repository at this point in the history
The instances of validates_uniqueness_of are replaced in favor of
the newer `validates :attribute, uniqueness: true` format or when
case insensitivity is required
`validates :attribute, uniqueness: { case_sensitive: false }`

Issue ref: #1092
  • Loading branch information
nicholasshirley authored and mcmire committed Apr 16, 2018
1 parent 7fd9ac6 commit c0960bd
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ActiveRecord
# pre-existing record (thereby failing the uniqueness check).
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :permalink
# validates :permalink, uniqueness: true
# end
#
# # RSpec
Expand Down Expand Up @@ -102,7 +102,7 @@ module ActiveRecord
# Use `on` if your validation applies only under a certain context.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :title, on: :create
# validates :title, uniqueness: true, on: :create
# end
#
# # RSpec
Expand All @@ -120,7 +120,7 @@ module ActiveRecord
# Use `with_message` if you are using a custom validation message.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :title, message: 'Please choose another title'
# validates :title, uniqueness: true, message: 'Please choose another title'
# end
#
# # RSpec
Expand All @@ -144,7 +144,7 @@ module ActiveRecord
# unique, but the scoped attributes are not unique either.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :slug, scope: :journal_id
# validates :slug, uniqueness: true, scope: :journal_id
# end
#
# # RSpec
Expand All @@ -165,7 +165,7 @@ module ActiveRecord
# attributes in the pre-existing record.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :key, case_sensitive: false
# validates :key, uniqueness: { case_sensitive: false }
# end
#
# # RSpec
Expand Down Expand Up @@ -193,7 +193,7 @@ module ActiveRecord
# attribute.
#
# class User < ActiveRecord::Base
# validates_uniqueness_of :email
# validates :email, uniqueness: true
#
# def email=(value)
# super(value.downcase)
Expand All @@ -217,7 +217,7 @@ module ActiveRecord
# Use `allow_nil` to assert that the attribute allows nil.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :author_id, allow_nil: true
# validates :author_id, uniqueness: true, allow_nil: true
# end
#
# # RSpec
Expand All @@ -237,7 +237,7 @@ module ActiveRecord
# Use `allow_blank` to assert that the attribute allows a blank value.
#
# class Post < ActiveRecord::Base
# validates_uniqueness_of :author_id, allow_blank: true
# validates :author_id, uniqueness: true, allow_blank: true
# end
#
# # RSpec
Expand Down

0 comments on commit c0960bd

Please sign in to comment.