Skip to content

Commit

Permalink
Allow collection input to accept a collection of symbols, closes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Aug 14, 2010
1 parent 7626fa4 commit cf99793
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/simple_form/inputs/collection_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def detect_collection_methods(collection, options)
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

Expand Down
7 changes: 7 additions & 0 deletions test/inputs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ def with_input_for(object, attribute_name, type, options={})
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
Expand Down

0 comments on commit cf99793

Please sign in to comment.