Skip to content

Commit

Permalink
Avoid implicit scoped_model.all delegation in the validation (#52)
Browse files Browse the repository at this point in the history
Validations are sometimes called in the deprecated leaking scoping rails/rails#35280 (e.g. `find_or_create_by` etc).

To avoid that warning, we should not delegate to (implicit) `scoped_model.all`.

Fixes #51.
  • Loading branch information
kamipo authored and Robin Bortlík committed Nov 17, 2019
1 parent 387744e commit 25ee467
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/validates_overlap/overlap_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def validate(record)
protected

def initialize_query(record, options = {})
self.scoped_model = options[:scoped_model].present? ? options[:scoped_model].constantize : record.class
scoped_model = options[:scoped_model].present? ? options[:scoped_model].constantize : record.class
self.scoped_model = scoped_model.default_scoped
generate_overlap_sql_values(record)
generate_overlap_sql_conditions(record)
add_attributes(record, options[:scope]) if options && options[:scope].present?
Expand Down

0 comments on commit 25ee467

Please sign in to comment.