diff --git a/lib/simple_form/inputs/collection_input.rb b/lib/simple_form/inputs/collection_input.rb index f18315da..1b0e6afe 100644 --- a/lib/simple_form/inputs/collection_input.rb +++ b/lib/simple_form/inputs/collection_input.rb @@ -46,7 +46,7 @@ module SimpleForm label, value = :first, :last when Integer label, value = :to_s, :to_i - when String, NilClass + when String, Symbol, NilClass label, value = :to_s, :to_s end diff --git a/test/inputs_test.rb b/test/inputs_test.rb index d03a9b36..9f485ecf 100644 --- a/test/inputs_test.rb +++ b/test/inputs_test.rb @@ -327,6 +327,13 @@ class InputTest < ActionView::TestCase assert_select 'label.collection_radio', 'CARLOS' end + test 'input should allow symbols for collections' do + with_input_for @user, :name, :select, :collection => [:jose, :carlos] + assert_select 'select.select#user_name' + assert_select 'select option[value=jose]', 'jose' + assert_select 'select option[value=carlos]', 'carlos' + end + # With no object test 'input should be generated properly when object is not present' do with_input_for :project, :name, :string