On Sun, Jul 12, 2009 at 9:50 PM, JangoSteve<[email protected]> wrote: > > I'm not sure this is what is causing your problem, but according to > your models, a Match has_many Playergames, which would mean that each > Playergame has a match_id, correct? However, in your script, you are > saving the Playergames before the Match, meaning a match_id has not > yet been created. When you do Playergame.find(:all), I'm assuming they > show match_id=nil. Anyway, I'd at least try changing your script to > save Match before Playergames, and see if you're still having > problems... > > #match.playergames << rick_game > #match.playergames << steve_game > > match.save > > #rick_game.save #this will save a game > #steve_game.save #this will save a game
Good point, about saving the games first, but I'm curious, what the heck is going on that I can't seem to get match to save even with those game save lines commented out (as above.) I'm just trying to get a Match to save. If I call match.save and it doesn't save shouldn't the script throw an error? I guess that's why I'm a little stumped since the script seems to fun just fine. When I use the rails app UI to add match it seems to save just fine as you can see by a quick call in the console: >> Match.find(:all) => [#<Match id: 1, match_date: "2009-07-12 00:00:00", overtime: false, shootout: false, linechanges: true, period_length: 20, game_version: nil, notes: nil>] I'm sure this is going to turn out to be something really stupid, so I'm ready for the 'duh' moment to hit me:) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

