-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
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
Error while Rails/UniqueValidationWithoutIndex cop was inspecting #1226
Comments
Unfortunately, I'm unable to reproduce the error. |
@koic Could you explain how Error: app/models/buyer_user_notifications_setting.rb:4:3: C: Rails/UniqueValidationWithoutIndex: Uniqueness validation should have a unique index on the database column.
validates :buyer_user_id, uniqueness: true
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Model: validates :buyer_user_id, uniqueness: true Schema: create_table "buyer_user_notifications_settings", force: :cascade do |t|
...
t.index ["buyer_user_id"], name: "index_buyer_user_notifications_settings_on_buyer_user_id", unique: true
end Migration: add_index :buyer_user_notifications_settings, :buyer_user_id, unique: true, if_not_exists: true Thank you! |
I think that might be the issue here then. This is a simple website that actually has no ActiveRecord::Schema.define(version: 0) do
end Regardless, it seems that @yashka713 still has this problem even with real |
Expected behavior
Expected rubocop to run without errors.
Actual behavior
Received the following errors:
Steps to reproduce the problem
Every single error was related to lines where I'm using
validates
. Here are some examples:It might be important to note this project doesn't have any
ActiveRecord
model classes and that these aren't actually* < ActiveRecord::Base
classes but are POROs that include some Rails functionality so they behave like ActiveRecord classes. Here's an example:Also note that I'm using
ruby 3.3.0p0
as well. I'm assuming because of the text in the errors though that this might be arubocop-rails
bug and not necessarily arubocop
bug.RuboCop version
The text was updated successfully, but these errors were encountered: