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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---