diff --git a/CHANGELOG.md b/CHANGELOG.md index ed059627..6ebfbb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 3.1.0.rc2 ### enhancements + * Add mapping to `uuid` columns. * Add custom namespaces for custom inputs feature. [@vala](https://github.com/vala) * Add `:unless_blank` option to the wrapper API. [@IanVaughan](https://github.com/IanVaughan) * Add support to html markup in the I18n options. [@laurocaetano](https://github.com/laurocaetano) diff --git a/README.md b/README.md index ea0bc266..5edbe3d0 100644 --- a/README.md +++ b/README.md @@ -521,6 +521,7 @@ specifying the helper method in the column `Mapping` as the `as:` option. `tel` | `input[type=tel]` | `string` with `name =~ /phone/` `password` | `input[type=password]` | `string` with `name =~ /password/` `search` | `input[type=search]` | - + `uuid` | `input[type=text]` | `uuid` `text` | `textarea` | `text` `file` | `input[type=file]` | `string` responding to file methods `hidden` | `input[type=hidden]` | - diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 52cf9be7..a05072f2 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -19,7 +19,7 @@ module SimpleForm map_type :text, to: SimpleForm::Inputs::TextInput map_type :file, to: SimpleForm::Inputs::FileInput - map_type :string, :email, :search, :tel, :url, to: SimpleForm::Inputs::StringInput + map_type :string, :email, :search, :tel, :url, :uuid, to: SimpleForm::Inputs::StringInput map_type :password, to: SimpleForm::Inputs::PasswordInput map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput map_type :range, to: SimpleForm::Inputs::RangeInput diff --git a/test/form_builder/general_test.rb b/test/form_builder/general_test.rb index 021260f5..7022ebeb 100644 --- a/test/form_builder/general_test.rb +++ b/test/form_builder/general_test.rb @@ -126,6 +126,11 @@ class FormBuilderTest < ActionView::TestCase assert_select 'form input#user_credit_limit.numeric.decimal' end + test 'builder generates uuid fields for uuid columns' do + with_form_for @user, :uuid + assert_select 'form input#user_uuid.string.uuid' + end + test 'builder generates password fields for columns that matches password' do with_form_for @user, :password assert_select 'form input#user_password.password' diff --git a/test/support/models.rb b/test/support/models.rb index 4d86a9e7..eff8341c 100644 --- a/test/support/models.rb +++ b/test/support/models.rb @@ -74,7 +74,7 @@ class User :avatar, :home_picture, :email, :status, :residence_country, :phone_number, :post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender, :extra_special_company_id, :pictures, :picture_ids, :special_pictures, - :special_picture_ids + :special_picture_ids, :uuid def self.build(extra_attributes = {}) attributes = { @@ -125,6 +125,7 @@ class User when :attempts then :integer when :action then :string when :credit_card then :string + when :uuid then :uuid end Column.new(attribute, column_type, limit) end