Skip to content
This repository
Browse code

generate HTML5 number_field tag for integer fields

  • Loading branch information...
commit 4d1752bfb225e6e973375e10f52063060b49e666 1 parent 12a4376
Akira Matsuda amatsuda authored
13 railties/lib/rails/generators/generated_attribute.rb
@@ -13,12 +13,13 @@ def initialize(name, type)
13 13
14 14 def field_type
15 15 @field_type ||= case type
16   - when :integer, :float, :decimal then :text_field
17   - when :time then :time_select
18   - when :datetime, :timestamp then :datetime_select
19   - when :date then :date_select
20   - when :text then :text_area
21   - when :boolean then :check_box
  16 + when :integer then :number_field
  17 + when :float, :decimal then :text_field
  18 + when :time then :time_select
  19 + when :datetime, :timestamp then :datetime_select
  20 + when :date then :date_select
  21 + when :text then :text_area
  22 + when :boolean then :check_box
22 23 else
23 24 :text_field
24 25 end
6 railties/test/generators/generated_attribute_test.rb
@@ -4,8 +4,12 @@
4 4 class GeneratedAttributeTest < Rails::Generators::TestCase
5 5 include GeneratorsTestHelper
6 6
  7 + def test_field_type_returns_number_field
  8 + assert_field_type :integer, :number_field
  9 + end
  10 +
7 11 def test_field_type_returns_text_field
8   - %w(integer float decimal string).each do |attribute_type|
  12 + %w(float decimal string).each do |attribute_type|
9 13 assert_field_type attribute_type, :text_field
10 14 end
11 15 end

0 comments on commit 4d1752b

Please sign in to comment.
Something went wrong with that request. Please try again.