123456789_123456789_123456789_123456789_123456789_

Exception: ActiveRecord::ImmutableRelation

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveRecordError, StandardError
Instance Chain:
self, ActiveRecordError, StandardError
Inherits: ActiveRecord::ActiveRecordError
Defined in: activerecord/lib/active_record/errors.rb

Overview

Raised when a relation cannot be mutated because it’s already loaded.

class Task < ActiveRecord::Base
end

relation = Task.all
relation.loaded? # => true

# Methods which try to mutate a loaded relation fail.
relation.where!(title: 'TODO')  # => ActiveRecord::ImmutableRelation
relation.limit!(5)              # => ActiveRecord::ImmutableRelation