readonly(value = true) public

Mark a relation as readonly. Attempting to update a record will result in an error.

users = User.readonly
users.first.save
=> ActiveRecord::ReadOnlyRecord: User is marked as readonly

To make a readonly relation writable, pass false.

users.readonly(false)
users.first.save
=> true
Show source
Register or log in to add new notes.