The default behavior for Ruby on Rails is to save changes made to collection associations. Is there a way to change this behavior so that I can modify the collections in memory without making any changes to the database.
So, if I have two classes:
class Project < ActiveRecord::Base
has_many :tasks
class Task < ActiveRecord::Base
belongs_to :project
and write some code:
Project.tasks.clear
Project.tasks << task1
Project.tasks << task2
then it automatically deletes all tasks related to the project and automatically writes the changes to db.
, . , Project.tasks.build(), , , , , . . . , Project.tasks.clear db.
java-, Hibernate, .