I have a situation where I have an ActiveRecord::Relation
object, where the relation's objects have some has_many
associations. There is another piece of code that deletes the database rows associated with this relation that doesn't go through the relation, using delete_all
. I know what the new state of the relation's associations is even without going to the database so I want to be able to set the object's attributes in this relation manually without touching the database again.
I found this article which mentions the write_attribute
method. This works, but it looks like it has been deprecated, so I'd rather not use. It also mentions attributes=
as a way of doing this without accessing the database. Is there something that can achieve the effect of write_attribute
where I won't access the database when modifying a relation's attributes?
Aucun commentaire:
Enregistrer un commentaire