I have the following associations.

class Document < ActiveRecord::Base
  has_many :document_sections, :dependent => :destroy, :autosave => true
  has_many :document_items, :through => :document_sections
end

class DocumentSection < ActiveRecord::Base
  belongs_to :document
  has_many :document_items, :dependent => :destroy, :autosave => true
end

class DocumentItem < ActiveRecord::Base
  belongs_to :document_section
end

When I use irb console to do

 d = Document.find_by_id(100)
 d.title = '1-comments'
 s = d.document_sections.find_by_id(200)
 s.title = '2-comments'
 i = s.document_items.find_by_id(10)
 i.comments = '3-comments'
 d.save

The changes to d, s, and i get saved to the database because of the
autosave option set to true in the model. However when I do the same in
a controller action, only the document header comments get saved. The
log only shows a sql update to the documents table but not the
document_sections and document_items table. Why is this behavior
different in a controller vs irb console.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to