We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given a model:
class Account < ApplicationRecord validates "some_field", uniqueness: true end
and a schema.rb:
schema.rb
enable_extension "plpgsql" create_table "accounts", force: :cascade do |t| t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "some_field" t.index ["some_field"], name: "some_field_index", unique: true end
Rubocop passes.
But changing the model validation to use a symbol rather than a string:
validates :some_field, uniqueness: true
It fails with:
C: Rails/UniqueValidationWithoutIndex: Uniqueness validation should be with a unique index
I would expect both of those to produce the same result.
0.80.1 (using Parser 2.7.0.5, running on ruby 2.7.0 x86_64-darwin19)
6.0.2.2
2.7.0 This appears to work as expected on Ruby 2.7.1
The text was updated successfully, but these errors were encountered:
I cannot reproduce this issue. RuboCop Rails 2.5.1 has been released. Will updating to RuboCop 2.5.1 reproduce the issue? https://github.com/rubocop-hq/rubocop-rails/releases/tag/v2.5.1
Sorry, something went wrong.
Turns out the issue actually has nothing to do with Symbols/Strings it's just changing the file at all that does it.
This is actually a duplicate of #227 so will close it.
No branches or pull requests
Given a model:
and a
schema.rb
:Rubocop passes.
But changing the model validation to use a symbol rather than a string:
validates :some_field, uniqueness: true
It fails with:
C: Rails/UniqueValidationWithoutIndex: Uniqueness validation should be with a unique index
I would expect both of those to produce the same result.
RuboCop version
0.80.1 (using Parser 2.7.0.5, running on ruby 2.7.0 x86_64-darwin19)
Rails version
6.0.2.2
Ruby version
2.7.0 This appears to work as expected on Ruby 2.7.1
The text was updated successfully, but these errors were encountered: