]> git.openstreetmap.org Git - rails.git/blob - app/models/relation_member.rb
Add feed action to relevant filters
[rails.git] / app / models / relation_member.rb
1 class RelationMember < ActiveRecord::Base
2   set_table_name 'current_relation_members'  
3   set_primary_keys :relation_id, :sequence_id
4
5   belongs_to :relation
6   belongs_to :member, :polymorphic => true
7
8   after_find :set_class_from_type
9   after_initialize :set_class_from_type
10   before_save :set_type_from_class
11
12   def member_type=(type)
13     self[:member_type] = type
14     self[:member_class] = type.capitalize
15   end
16
17 private
18
19   def set_class_from_type
20     self[:member_class] = self.member_type.classify unless self.member_type.nil?
21   end
22
23   def set_type_from_class
24     self.member_type = self[:member_class].classify
25   end
26 end