0

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.

le_me
  • 3,089
  • 3
  • 26
  • 28
  • You could have `Unknown` route and assign to it all Stations that don't have real Route yet. ANd later, when you get real Route you could reassign those Stations... – Yevgeniy Anfilofyev Sep 12 '13 at 06:53
  • that's a good workaround, thank you! but I think it should be possible to do it directly in datamapper ;) – le_me Sep 13 '13 at 04:44

0 Answers0