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

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.