app/models/relationship.rb in acts-as-joinable-0.1.7.4 vs app/models/relationship.rb in acts-as-joinable-0.1.7.5
- old
+ new
@@ -1,3 +1,17 @@
class ActsAsJoinable::Relationship < ActiveRecord::Base
acts_as_relationship
-end
\ No newline at end of file
+
+ 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