Search code examples
ruby-on-rails-3after-save

after_save callback with virtual attributes Rails 3


I don't know if this is possible so I thought I would ask.

1. Give a model some virtual attributes
2. Assign values to the model and the virtual attributes
3. Save the model 
4. Use a callback after_save to create a different object with the virtual attributes.

Can this be done in Rails 3?


Solution

  • As long as associations are irrelevant for you, use:

    http://apidock.com/rails/ActiveRecord/Base/clone