Problem in updating the association object attributes

Assuming that the tables are in the same database, you can do it in a single transaction, albeit not in a single save.

Library.transaction do   @library.update_attributes(params[:book])   @book.update_attributes(params[:library]) end

Whether you use Library or Book as the receiver of the transaction method shouldn't matter since the transaction applies to the database connection which is shared assuming, as I said, that both tables are in the same DB.