略過至內容 略過至搜尋

關係無法變更時擲出,因為關係已載入。

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::UnmodifiableRelation
relation.limit!(5)              # => ActiveRecord::UnmodifiableRelation