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
Creating Place + Geolocation is ok ,
= simple_form_for @place, :url => backoffice_places_path, :html =>
{:class
=> ‘form-vertical’ } do |f|
…
= f.simple_fields_for :geolocation do |g|
= render “geolocation_fields”, :f => g
Editing Place + geolocation doesnt pass , the update method receives
the
new geolocation attributes from the form, but the geolocation instance
is
not updated… ( no validation error )
= simple_form_for @place, :url => backoffice_place_path, :html =>
{:method
=> :put, :class => ‘form-vertical’ } do |f|
…
= f.simple_fields_for :geolocation_attributes, @place.geolocation
do
|g|
= render “geolocation_fields”, :f => g
Place controller
def edit
@place = Place .find(params[:id])
def update
debugger
if @place.update_attributes(params[:place])
debugger
redirect_to backoffice_place_path(@place), notice:
t(:place_updated)
params
{“id”=>“76”, “geolocation_attributes”=>{“street_address”=>“19 Camp
Road”,
“postal_code”=>“Greater London SW19 4UW”, “city”=>“London”,
“country”=>“United Kingdom”}, “controller”=>“backoffice/places”,
“action”=>“update”}
any ide where I am wrong ? thanks for any clue