Bryan Larsen
unread,Mar 19, 2009, 10:35:42 PM3/19/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Hobo Users
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