i'm getting data from a third party with own unique keys.
Level1, data_provider_id Level2, level_1_id, data_provider_id Level3,level_2_id, data_provider_id
Relations for level1.rb
has_many :level2s, :primary_key => :data_provider_id
has_many :level3s, :through => :level2s
Relations for level2.rb
has_many :level3s, :primary_key => :data_provider_id
If I want to create own Levels i will have to assign a data_provider_id for the relations to work. I could take negative numbers or a range i know the 3rd party will never use but i don't like that approach. Is there a way to make the relation work like the default way when the data_provider_id is nil ?
I tried:
has_many :level2s, :primary_key => (:data_provider_id == nil ? :id : :data_provider_id)
But that doesn't work.
Thanks in advance