diff options
author | Akira Matsuda <ronnie@dio.jp> | 2011-05-16 23:43:05 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2011-05-16 23:45:39 +0900 |
commit | 4d1752bfb225e6e973375e10f52063060b49e666 (patch) | |
tree | c78f0bfbc9eb10cf6ebeaf7bec54e556655e7e25 | |
parent | 12a4376ae96f79ec0ba889a70a4390531d1d6ffd (diff) | |
download | rails-4d1752bfb225e6e973375e10f52063060b49e666.tar.gz rails-4d1752bfb225e6e973375e10f52063060b49e666.tar.bz2 rails-4d1752bfb225e6e973375e10f52063060b49e666.zip |
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 |