1 class RelationMember < ActiveRecord::Base
2 set_table_name 'current_relation_members'
4 set_primary_keys :id, :sequence_id
6 belongs_to :member, :polymorphic => true
7 belongs_to :relation, :foreign_key => :id
9 after_find :set_class_from_type
10 after_initialize :set_class_from_type
11 before_save :set_type_from_class
13 def member_type=(type)
14 self[:member_type] = type
15 self[:member_class] = type.capitalize
20 def set_class_from_type
21 self[:member_class] = self.member_type.classify unless self.member_type.nil?
24 def set_type_from_class
25 self.member_type = self[:member_class].classify