views:

28

answers:

1

If i have

class User < ActiveRecord::Base
  has_many :books
end

.

class Book < ActiveRecord::Base
  belongs_to :user
end

Question: When i save an instance of Book, will it call save on its associated User as well?

In my code base im finding that when i call @somebook.save, 'User's after_save callbacks are being executed.

A: 

Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

gsoni
Calling save on an object does not save the object?
Mike