I have two tables in MySQL: football_fixtures and weekly_fixtures.
In my code I have two classes
class FootballFixture
end
and
class WeeklyFixture
has_many :football_fixtures
end
the WeeklyFixture class has more code than this, mostly validation
In the console window I do this
wf = WeeklyFixture.new
wf.somefield = somevalue
wf.save!
and everything is OK
however if I do
wf = WeeklyFixture(6) # where 6 is an id in the table so the wf is
found!
wf.football_fixtures[0].name = “value”
wf.save!
I get a return value of true, but no data is written to the database.
I have the log visible on another terminal (tail -f development.log),
and I don’t see any update call being made. (I do see selects being
made when I read the records)
I think I’m missing something fundamental here. I assumed that when I
updated the related fields and wrote the parent model the the DB then
the save would also write the related fields, but this is not
happening.
BTW, if I do
wf.football_fixtures[0].save
that does work!
What (presumably simple) magic incantation am I missing?
Thanks,
Kevin Jones