Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1087 from amatsuda/generate_number_field_tag

generate HTML5 number_field tag for integer fields
  • Loading branch information...
commit 40fa51123d47053da9b5ed7d38ba7c1b6432a651 2 parents 12a4376 + 4d1752b
José Valim josevalim authored
13 railties/lib/rails/generators/generated_attribute.rb
View
@@ -13,12 +13,13 @@ def initialize(name, type)
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
6 railties/test/generators/generated_attribute_test.rb
View
@@ -4,8 +4,12 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.