On Jul 19, 2008, at 9:18 AM, David Dollar wrote:
> On a related-yet-slightly-different-topic note: > > p = Project.find(:first) > p.tasks.first.name = 'New Name' > p.save > > does not update the Task in the database. I'd like to get some > thoughts/opinions on using dirty tracking to make cascadable saves > possible. > > If I could cascade the saves, it becomes a lot easier to bubble up > validations in a format that makes sense for nested associations. Whoa pardner, that's dangerously close to the Unit-of-Work pattern there! I like this idea (it's been discussed before many times), but it's a huge change to how things work. Much moreso than just partial updates. I'm all for it though. The big issue I see is finding the associated objects that need saving. AR isn't good at dealing with partially loaded has_many association collections. I think you'd need a new API on associations to enumerate the already loaded records and see which are dirty and need saving. p = Project.find(some_id) task = p.tasks.find_by_name("send invoice") task.due_date = 3.days.from_now p.build_task(task_params) p.save There's a lot that would need to happen to make that example work, and maybe that's even reaching a bit too far. Anyway, just thinking out loud. -- Josh Susser http://blog.hasmanythrough.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---