instance method strict_loading

Ruby on Rails 8.1.2

Since v6.1.7.10

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

strict_loading(value = true)

Sets the returned relation to strict_loading mode. This will raise an error if the record tries to lazily load an association.

user = User.strict_loading.first
user.comments.to_a
# => ActiveRecord::StrictLoadingViolationError

Parameters

value opt = true
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 1325
    def strict_loading(value = true)
      spawn.strict_loading!(value)
    end

Defined in activerecord/lib/active_record/relation/query_methods.rb line 1325 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::QueryMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close