I came to the solution using the has_many_polymorphs plugins:

The correct modelling is:

class Relationship < ActiveRecord::Base

  belongs_to :relationship_owner, :polymorphic => true
  belongs_to :relationship_partner, :polymorphic => true

  acts_as_double_polymorphic_join(
        :relationship_owners =>[:people, :realties, :documents],
        :relationship_partners => [:people, :realties, :documents]
  )

end

... and the migration:

class CreateRelationships < ActiveRecord::Migration
  def self.up
    create_table :relationships do |t|
      t.string :name

      t.references :relationship_owner, :polymorphic => true
      t.references :relationship_partner, :polymorphic => true

      t.timestamps
    end
  end

  def self.down
    drop_table :relationships
  end
end
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to