views:

26

answers:

1
class Article
  has_many Comments
end

class Comments
  belongs_to Article
end

# Logic for importing Comments and Ratings
a = Article.find_by_name(name)
a.comments = comments # comments list gets saved.
                      # I want to delay this
#
# some other logic
#

Article.transaction
# save Comments 
# save Ratings

end

In the above example how do I disable the auto saving of comments collection?

A: 

Don't save add the comments to the article until after you've saved the article.

pjb3
Adding comments to articles is done by a method which is not under my control. I need a way to set the auto_save OFF during the import context and perform all the DB operations in one transaction.
KandadaBoggu