Save does not cascade in 1.2.1?

Hi All,

I have the following test case which worked just fine before I upgraded
to rails 1.2.1:

def test_update_settings
assert @unit.setting!=nil # loaded via fixtures
assert_equal @unit.setting,@current_setting # also loaded via
fixtures
@unit.setting.mode = true
assert @unit.save
@unit.reload
assert @unit.setting.mode
end

where @unit is declared with ‘has_one :setting’ setting and setting is
declared as ‘belongs_to: unit’
After I upgraded to rails 1.2.1 ‘@unit.save’ stopped cascading the
update on setting and as a consequence the last assert fails. When I
check the log I see that no update happens on the child (setting). Do I
miss anything? Can someone confirm whether it works or broken?

Regards,
Siarhei

When I
check the log I see that no update happens on the child (setting). Do I
miss anything? Can someone confirm whether it works or broken?
Have you checked to see if any validations are failing on the child
model? If you update a child via a parent and validations fail, rails
will fail the save silently and you’ll see no sql update in the
logs.

Steve

Stephen B. wrote:

When I
check the log I see that no update happens on the child (setting). Do I
miss anything? Can someone confirm whether it works or broken?
Have you checked to see if any validations are failing on the child
model? If you update a child via a parent and validations fail, rails
will fail the save silently and you’ll see no sql update in the
logs.

Yes I tried that and the child was valid.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs