Erwin1
(Erwin)
1
I have a nested model Place => Geolocation
class Place < ActiveRecord::Base
has_one :geolocation, :dependent => :destroy
accepts_nested_attributes_for :geolocation, :reject_if => :all_blank, :allow_destroy => true
attr_accessible :geolocation_attributes
class Geolocation < ActiveRecord::Base
belongs_to :place
Erwin1
(Erwin)
2
[SOLVED] in my functional test I had a bad :put ,
assert_difference [ ‘Place.count’, ‘Geolocation.count’ ], 0 do
put :update, :id => @place[:id],
:geolocation_attributes => {
street_address: @street_address,
postal_code: @postal_code,
city: @city,
country: @country }
end
when I should have added the :place => { :geolocation_attributes => { !!
assert_difference [ ‘Place.count’, ‘Geolocation.count’ ], 0 do
put :update, :id => @place[:id], :place => {
:geolocation_attributes => {
street_address: @street_address,
postal_code: @postal_code,
city: @city,
country: @country }
}
end
updating correctly now