> I think he's referring to Approach 2 (of http://gist.github.com/gists/10793 > ) which has both a new_task_attributes and existing_task_attributes > accessor. I'm not very fond of this either, especially when you're > setting it directly through Ruby and not using form params.
Thanks for clarifying. > BTW Eloy, I saw your idea of using the timestamp when adding new task > records (through javascript). Genius! Thanks :) > What if we support both Approach 1 and Approach 4? Here's the logic in > pseudo code. > > -- > def tasks=(new_tasks) > if new_tasks is a hash > grab values (as array) and sort by keys > call self.tasks= with new values array > else > for each task in new_tasks > if task is hash > if task has id key > update existing task matching id > else > add new task with hash attributes > end > else > add task > end > end > end > end > -- > > Supporting both hashes and arrays opens up a lot of flexibility. > Generally you'd use an array when dealing directly in Ruby, but a hash > when going through a form. I agree. I think I already support what you mean. But maybe it would be an idea if you could send me a test which tests the difference in behaviour between a Hash and a Array so I can verify? Cheers, Eloy --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---
