Browse files

Ensure :index works with fields_for select methods. [#518 state:resol…


Signed-off-by: Pratik Naik <>
  • Loading branch information...
1 parent 0d241f4 commit 95812d5eafc3b63ce5eeb0748a5d0132f5108b64 rsl committed with lifo Jul 13, 2008
@@ -445,19 +445,19 @@ def add_options(option_tags, options, value = nil)
class FormBuilder
def select(method, choices, options = {}, html_options = {})
-, method, choices, options.merge(:object => @object), html_options)
+, method, choices, objectify_options(options), @default_options.merge(html_options))
def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
- @template.collection_select(@object_name, method, collection, value_method, text_method, options.merge(:object => @object), html_options)
+ @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options))
def country_select(method, priority_countries = nil, options = {}, html_options = {})
- @template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
+ @template.country_select(@object_name, method, priority_countries, objectify_options(options), @default_options.merge(html_options))
def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
- @template.time_zone_select(@object_name, method, priority_zones, options.merge(:object => @object), html_options)
+ @template.time_zone_select(@object_name, method, priority_zones, objectify_options(options), @default_options.merge(html_options))
Oops, something went wrong.

6 comments on commit 95812d5


rsl commented on 95812d5 Jul 14, 2008

What a strange looking commit. :) Is it my browser? A lot of empty lines.


ncr replied Jul 14, 2008

Looks like some kind of funny injection testing :)


yaroslav replied Jul 14, 2008

selects are really nice

I hope they escape coments.


ncr replied Jul 14, 2008

They do now :)

I am attempting to utilize mass-assign for my models, but can’t get the update_attributes to work correctly when I have association_collections as child models.
My create methods work fine, since the hash passes in an Array value for these collections. I.E.:
emails => [ {…}, {…} ] )
But, when I try to edit/update my model, the field names in the form naturally have the :id of the email included in them, so that the resulting value passed to the mass-assign is not an Array, but a Hash of this form:
emails => {“5” => {…}, “6” => {…}}
Where the 5 and 6 are the :id values of the respective emails. This gets passed into the update_attributes, which eventually gets to:
which assumes “emails” to be an Array. Shouldn’t this replace method be “smarter” so that if a Hash is passed in, it will ascertain the :id values from it, and then reassign the model attributes accordingly?
Furthermore, what would happen if there were a combination of updated models (emails) and perhaps one new email (that didn’t have an :id). Does the mass-assign functionality handle this situation?
Any help would be appreciated.

Please sign in to comment.