I have three tables:
class Name
  include DataMapper::Resource

  property  :id,  Serial
  property  :normalized_name,   String, :unique_index =>
true, :required => true
  property  :name,              String, :required => true
  property  :link_status,       Enum, :flags =>
[:new, :linked], :default => :new
  has n, :people_names
  has n, :people, :through => :people_names

  def name=(value)
    attribute_set(:name, value.upcase)
    attribute_set(:normalized_name, Name.normalize(value))
  end

  def Name.normalize(orig_name)
    n = orig_name.upcase
    n.gsub!(',', '')
    n.gsub!('.', '')
    n.gsub!(' ', '')
    n
  end
end

class Person
  include DataMapper::Resource
  property :id,   Serial
  property :name, String
  has n, :people_names
  has n, :names, :through => :people_names
end

class PeopleName
  include DataMapper::Resource
  property :id,   Serial
  property :link_type,      Enum, :flags =>
[:validated, :unvalidated], :default => :unvalidated
  belongs_to :person
  belongs_to :name
end

I create a Person object as p  and a Name object as n, when I assign
p.names << name and n.person << person I can then do p.names and I get
the name assigned, same with n.person I get the right person. But how
do I access the :link_type property from the PeopleName table.  If I
do a PeopleName.all I get an empty array.

How do I access the additional information in the join table?

Don French

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en.

Reply via email to