Hi,
I have a model Member containing details such as name, address, phone, etc.
There are various approval stages for new and changed members so I need a few
extra models based on member, some can use STI, some I'd prefer not to use
STI.
MemberMod which stores a modified member in the members table using STI. This is necessary because there are approval stages to a modification. This is working fine and the simplified model looks like this:
class MemberMod < Member belongs_to :original_member, :class_name => 'Member', :foreign_key => :original_member_id end
I have a few other models that are very similar to MemberMod (such as MemberTransfer) which should have no problem using the STI method, however ...
I'm now creating a MemberProposal model which needs all the fields of a Member and a bunch more. I was planning to use a member_proposals table for the extra details but to store the routine member details in the members table (to avoid duplicating it all) - however I need the record in members table to be easily recognizable as a "proposed member" not a "member" - I have issues, here's the simplified model:
class MemberProposal < ActiveRecord::Base # most details we store in a member record with type set to MemberProposal belongs_to :member end
The issue is that when I try to access models that belong_to member it fails, things like:
member_proposal.member.club member_proposal.member.state member_proposal.member.country
It fails because it thinks Member is a MemberProposal and not a Member (technically I suppose it's correct). Is there any way to turn off the magic interpretation of member[:type] for this use case or do I need to change my scheme entirely?
Thanks