Hi gys i am trying to link two entities to one entity which is governing body, estate and repo_document, then a governing body can have repo_document that the estate can also have so i decided to create a join table named document_owner.. but i dont know what to write in their models..i have got this code in my document_owner model..
belongs_to :repo_document belongs_to :estate, :through => :repo_document, :foreign_key => :owner_id, :conditions => "owner_type = 'Estate'" belongs_to :governing_body, :through => :repo_document, :foreign_key => :owner_id, :conditions => "owner_type = 'GoverningBody'" belongs_to :owner, :polymorphic => true
and this one in my repo_document
has_and_belongs_to_many :owners, :join_table => :document_owners, :conditions => "owner_type = 'Estate' OR owner_type = 'GoverningBody'"
and this one in my estate
has_many :repo_documents, :source => :document_owners, :foreign_key => :owner_id, :conditions => "owner_type = 'Estate' "
and this one in my governing_body
has_many :repo_documents, :source => :document_owners, :foreign_key => :owner_id, :conditions => "owner_type = 'GoverningBody' "
but when i try to save it does not save anything inside the join table..
can anybody help me please