Forum: Ruby on Rails autosave no longer a valid option for belongs_to?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E4f8e60d8db78514931ab6ff4073ab4f?d=identicon&s=25 Jason Fox (jfoxny)
on 2009-03-10 21:49
The Rails API doc (api.rubyonrails.org) says that :autosave is still a
valid option for belongs_to in the latest version of Rails.  However, a
look at the activerecord/lib/active_record/associations.rb (line 1590)
reveals that it is not in the @@valid_keys_for_belongs_to_association
array. I also noticed that it's not in the ActiveRecord API doc
(ar.rubyonrails.org).

Does anyone have any more information on this?  What is the current best
practice for persisting your child objects when saving a parent object?
Here's an example:

class PaymentMethod < ActiveRecord::Base
  belongs_to :billing_address, :class_name => "Address"
end
class Address < ActiveRecord::Base
  validates_presence_of :line_one
end
class PaymentMethodsController < ActionController::Base
  def update
    @pm = PaymentMethod.find(params[:id])
    @pm.billing_address.line_one = params[:billing_address][:line_one]
    # ...
    if @pm.save
      # ...
    end
  end
end

Thanks in advance.

Jason
29ebf90af6107d2eb39b587c7972639c?d=identicon&s=25 Mukund (Guest)
on 2009-06-04 12:04
(Received via mailing list)
Whats the resolution for this?


On Mar 11, 1:49 am, Jason Fox <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.