class ActsAsJoinable::Relationship < ActiveRecord::Base acts_as_relationship def swap_parent_and_child old_parent_type = self.parent_type old_parent_id = self.parent_id old_child_type = self.child_type old_child_id = self.child_id self.parent_type = old_child_type self.parent_id = old_child_id self.child_type = old_parent_type self.child_id = old_parent_id self.save! end end