How do I create a new instance of a different class when saving a model
        Posted  
        
            by Will
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Will
        
        
        
        Published on 2010-03-29T19:15:55Z
        Indexed on 
            2010/03/29
            19:23 UTC
        
        
        Read the original article
        Hit count: 231
        
ruby-on-rails
|activerecord
I have a Class A that when it is instantiated and saved for the first time or modified it will create an instance of Class B and save it also
I want them to be in the same transaction and I want it to be handled in the Model not a controller.
I know how to do this in a conteoller with the ‘transaction do’ block but how do I do it in the model?
Thanks
© Stack Overflow or respective owner