> Re. Josh's comment on ordering, as long as you use a hash you're safe,
> right? You can order by the hash key -- I'm not missing anything?
> (perhaps around javascript drag-and-drop reordering?)

Indeed. That's actually what he opted for with that comment, if I  
understood correctly.

> Like Eloy's implementation, in my project I specify whether or not I
> want to destroy records that are missing from the hash, by
> a :destroy_missing option on the has_many declaration. But I
> definitely agree that the best implementation would be to match what
> ActiveRecord already does for tasks= when taking an array of objects
> rather than a params hash -- which is, according to the docs:
> "Replaces the collection's content by deleting and adding objects as
> appropriate."

Agreed, it seems to follow the principle of least surprise.
However, I wonder if that might have to do with the fact that
using a has_many writer method is usually not used in combination with  
mass assignment....?

I guess for me it just doesn't feel right if by default stuff will get  
deleted,
where one might expect that you are simply updating the attributes.
But this may very well just be me being "paranoia" :)
Comments?

> Re. Eloy's :reject_empty option: I never create records if all the
> attributes are blank (i.e. the user presses the "add another task"
> button but leaves the task completely blank). Is there really a use
> case for that? In fact, if a user deletes all the content from the
> fields of an existing task, my implementation would delete that
> record.

Using the :reject_empty option as a default might indeed be sensible.

Deleting records for which we get a empty hash however is a different  
case.
The problem is that you might not always be sending
all attributes of a record. Thus assuming that a empty hash also means  
that
all the attributes of a record are empty is a bit dangerous.
There are ways to solve this of course, but that is not something I  
would
like to have by default.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to