diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-16 07:54:02 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-16 07:54:02 -0700 |
commit | 40fa51123d47053da9b5ed7d38ba7c1b6432a651 (patch) | |
tree | c78f0bfbc9eb10cf6ebeaf7bec54e556655e7e25 | |
parent | 12a4376ae96f79ec0ba889a70a4390531d1d6ffd (diff) | |
parent | 4d1752bfb225e6e973375e10f52063060b49e666 (diff) | |
download | rails-40fa51123d47053da9b5ed7d38ba7c1b6432a651.tar.gz rails-40fa51123d47053da9b5ed7d38ba7c1b6432a651.tar.bz2 rails-40fa51123d47053da9b5ed7d38ba7c1b6432a651.zip |
Merge pull request #1087 from amatsuda/generate_number_field_tag
generate HTML5 number_field tag for integer fields
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 13 | ||||
-rw-r--r-- | railties/test/generators/generated_attribute_test.rb | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index b26161f1d0..9450894b05 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -13,12 +13,13 @@ module Rails def field_type @field_type ||= case type - when :integer, :float, :decimal then :text_field - when :time then :time_select - when :datetime, :timestamp then :datetime_select - when :date then :date_select - when :text then :text_area - when :boolean then :check_box + when :integer then :number_field + when :float, :decimal then :text_field + when :time then :time_select + when :datetime, :timestamp then :datetime_select + when :date then :date_select + when :text then :text_area + when :boolean then :check_box else :text_field end diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb index 064546a3f3..0d2e624f44 100644 --- a/railties/test/generators/generated_attribute_test.rb +++ b/railties/test/generators/generated_attribute_test.rb @@ -4,8 +4,12 @@ require 'rails/generators/generated_attribute' class GeneratedAttributeTest < Rails::Generators::TestCase include GeneratorsTestHelper + def test_field_type_returns_number_field + assert_field_type :integer, :number_field + end + def test_field_type_returns_text_field - %w(integer float decimal string).each do |attribute_type| + %w(float decimal string).each do |attribute_type| assert_field_type attribute_type, :text_field end end |