instance method strict_loading!

Ruby on Rails 6.1.7.10

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!()

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

user = User.first
user.strict_loading!
user.comments.to_a
=> ActiveRecord::StrictLoadingViolationError
Source
# File activerecord/lib/active_record/core.rb, line 702
    def strict_loading!
      @strict_loading = true
    end

Defined in activerecord/lib/active_record/core.rb line 702 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Core

Type at least 2 characters to search.

↑↓ navigate · open · esc close