How to create an OPTIONAL many-to-many association in data_mapper?

53 views Asked by At

I'm sorry, I can't ask the question better. I want to be able to create a Station and save it into the db, without having to know about the route yet. How do I have to change my models?

class Station
  include DataMapper::Resource

  property :id,         String, :key => true

  has n, :routes, :through => Resource
end

class Route
  include DataMapper::Resource

  property :id,   Serial, :key => true

  has n, :stations, :through => Resource
end

I'm using rubinius, data_mapper 1.2 and mariadb.

0

There are 0 answers