Hello,
I'm trying to update has-many to support zero-length associations.
When the association is empty, the view doesn't send any information
about the association to the controller. Hobo's magic controller then
thinks "he's not updating the association" rather than "he's updating
the association to be an empty list."
So I need some way of sending an empty list from the view to Rails'
param hash.
So far, I haven't found a way of doing that. Instead, I pass back an
empty string, and have patched Hobo like below. (I'm not submitting
the patch below, I'm just using it for illustration)
Anybody have any better ideas?
thanks,
Bryan
diff --git a/hobo/lib/hobo/accessible_associations.rb b/hobo/lib/hobo/
accessible
index 20317c7..aefbe29 100644
--- a/hobo/lib/hobo/accessible_associations.rb
+++ b/hobo/lib/hobo/accessible_associations.rb
@@ -53,6 +53,8 @@ module Hobo
def params_hash_to_array(array_or_hash)
if array_or_hash.is_a?(Hash)
array = array_or_hash.get(*array_or_hash.keys.sort_by
(&:to_i))
+ elsif array_or_hash.is_a?(String)
+ []
else
array_or_hash
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---