#143 √ resolved
Richard Grundy (RichGuk)

select_control and select_field error when using :collection => %w(one two three)

Reported by Richard Grundy (RichGuk) | August 15th, 2008 @ 04:01 PM | in 0.9.5

<%= select_control :foo, :collection => %w(one two three) %>

Will throw: undefined method 'foo' for one:String

I think the problem might be to do with this method (around line 122 of merb_helpers-0.9.5/lib/merb_helpers/form/builder.rb):

def update_select_control_field(method, attrs)

  attrs[:value_method] ||= method
  attrs[:text_method] ||= attrs[:value_method] || :to_s
  attrs[:selected] ||= @obj.send(attrs[:value_method])
end

So I think it's attempting to give a value_method, text_method of the first param passed into select_control (:foo).

Quick work around I've found this works:

<%= select_control :foo, :collection => %w(one two three), :value_method => :to_s, :text_method => :to_s %>

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins