Hello, I'm writing a backend for my iPhone app in Sinatra (ruby), using datamapper as my ORM. I have two models that have a many-to-many relationship:
*class Player* * include DataMapper::Resource* * * * property :id, Serial* * * * has n, :leagues, :through => Resource* *end* * * *class League* * include DataMapper::Resource* * * * property :id, Serial* * * * has n, :players, :through => Resource* *end* And the join table is created automatically for me upon the execution of: *DataMapper.finalize* *DataMapper.auto_upgrade!* However, I need to add an extra field to the join table 'is_referee'. I tried to reopen the LeaguePlayers class in Sinatra, and just the field like so: *class LeaguePlayers* * include DataMapper::Resource* * * * property :is_referee, Boolean, :default => false* *end* before I executed finalize & auto_upgrade!, but then datamapper yelled at me for not giving LeaguePlayers a primary key, so I just added in: * property :id, Serial* hoping it would all work out, but now I'm getting an error that doesn't give me any clear direction to go in: *dm-do-adapter.rb:70:in `execute_non_query': Cannot add a NOT NULL column with default value NULL (DataObjects::SyntaxError)* * * I'm new to ORMs in general. Could someone let me know how to create this join table field, and, afterwards how to query it? Thanks! ~nick -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To view this discussion on the web visit https://groups.google.com/d/msg/datamapper/-/jdyrV1Sh9YEJ. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.