class Post has_one :author, :autosave => true end The autosave will take care of saving associations when the parent is saved.
On May 28, 2:19 pm, Milan Dobrota <rails-mailing-l...@andreas-s.net> wrote: > Having one to many connection (for example post has many comments), what > is the most efficient way of saving all comments when post is saved. > Using after_save on Post would introduce the n+1 problem. Is there any > way of saving the whole structure at once? > -- > Posted viahttp://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@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 -~----------~----~----~----~------~----~------~--~---