Is there a better way of writing this code? It just doesn't sit right with me, I feel like there is something really 'rails like' that I should already know:
belongs_to :parent_in_use
belongs_to :parent_template
def after_create
new_parent_in_use = ParentInUse.create!(self.parent_template.attributes)
self.update_attribute(:parent_in_use_id, new_parent_in_use.id)
end
After creating a record I am taking the selected parent template and creating a parent_in_use
record based on it. This way the template can change and the in_use record will live with my object forever. Both the ParentInUse and ParentTemplate classes inherit from Parent using STI.
I'm sure this should be simple enough but I don't know how to do it, basically I would like to create the and assign the record in one operation.