diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 6b0c0527..949d1931 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -552,12 +552,12 @@ module SimpleForm :datetime when :string, :citext, nil case attribute_name.to_s - when /\bpassword\b/ then :password - when /\btime_zone\b/ then :time_zone - when /\bcountry\b/ then :country - when /\bemail\b/ then :email - when /\bphone\b/ then :tel - when /\burl\b/ then :url + when /(?:\b|\W|_)password(?:\b|\W|_)/ then :password + when /(?:\b|\W|_)time_zone(?:\b|\W|_)/ then :time_zone + when /(?:\b|\W|_)country(?:\b|\W|_)/ then :country + when /(?:\b|\W|_)email(?:\b|\W|_)/ then :email + when /(?:\b|\W|_)phone(?:\b|\W|_)/ then :tel + when /(?:\b|\W|_)url(?:\b|\W|_)/ then :url else file_method?(attribute_name) ? :file : (input_type || :string) end diff --git a/test/form_builder/general_test.rb b/test/form_builder/general_test.rb index 249d2cf8..469eb4a0 100644 --- a/test/form_builder/general_test.rb +++ b/test/form_builder/general_test.rb @@ -271,6 +271,11 @@ class FormBuilderTest < ActionView::TestCase assert_select 'form select#user_age.select' end + test 'builder does not generate url fields for columns that contain only the letters url' do + with_form_for @user, :hourly + assert_no_select 'form input#user_url.string.url' + end + test 'builder allows overriding default input type for text' do with_form_for @user, :name, as: :text assert_no_select 'form input#user_name' diff --git a/test/support/models.rb b/test/support/models.rb index a8e9febf..ca83f44e 100644 --- a/test/support/models.rb +++ b/test/support/models.rb @@ -91,7 +91,7 @@ class User :post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender, :extra_special_company_id, :pictures, :picture_ids, :special_pictures, :special_picture_ids, :uuid, :friends, :friend_ids, :special_tags, :special_tag_ids, - :citext, :hstore, :json, :jsonb + :citext, :hstore, :json, :jsonb, :hourly def self.build(extra_attributes = {}) attributes = {