Add mapping to uuid

Fixes #1085
This commit is contained in:
Rafael Mendonça França 2014-07-07 21:14:49 -03:00
parent 01ccfcebd4
commit 19cb663518
5 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,7 @@
## 3.1.0.rc2 ## 3.1.0.rc2
### enhancements ### enhancements
* Add mapping to `uuid` columns.
* Add custom namespaces for custom inputs feature. [@vala](https://github.com/vala) * 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 `: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) * Add support to html markup in the I18n options. [@laurocaetano](https://github.com/laurocaetano)

View File

@ -521,6 +521,7 @@ specifying the helper method in the column `Mapping` as the `as:` option.
`tel` | `input[type=tel]` | `string` with `name =~ /phone/` `tel` | `input[type=tel]` | `string` with `name =~ /phone/`
`password` | `input[type=password]` | `string` with `name =~ /password/` `password` | `input[type=password]` | `string` with `name =~ /password/`
`search` | `input[type=search]` | - `search` | `input[type=search]` | -
`uuid` | `input[type=text]` | `uuid`
`text` | `textarea` | `text` `text` | `textarea` | `text`
`file` | `input[type=file]` | `string` responding to file methods `file` | `input[type=file]` | `string` responding to file methods
`hidden` | `input[type=hidden]` | - `hidden` | `input[type=hidden]` | -

View File

@ -19,7 +19,7 @@ module SimpleForm
map_type :text, to: SimpleForm::Inputs::TextInput map_type :text, to: SimpleForm::Inputs::TextInput
map_type :file, to: SimpleForm::Inputs::FileInput 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 :password, to: SimpleForm::Inputs::PasswordInput
map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput
map_type :range, to: SimpleForm::Inputs::RangeInput map_type :range, to: SimpleForm::Inputs::RangeInput

View File

@ -126,6 +126,11 @@ class FormBuilderTest < ActionView::TestCase
assert_select 'form input#user_credit_limit.numeric.decimal' assert_select 'form input#user_credit_limit.numeric.decimal'
end 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 test 'builder generates password fields for columns that matches password' do
with_form_for @user, :password with_form_for @user, :password
assert_select 'form input#user_password.password' assert_select 'form input#user_password.password'

View File

@ -74,7 +74,7 @@ class User
:avatar, :home_picture, :email, :status, :residence_country, :phone_number, :avatar, :home_picture, :email, :status, :residence_country, :phone_number,
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender, :post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender,
:extra_special_company_id, :pictures, :picture_ids, :special_pictures, :extra_special_company_id, :pictures, :picture_ids, :special_pictures,
:special_picture_ids :special_picture_ids, :uuid
def self.build(extra_attributes = {}) def self.build(extra_attributes = {})
attributes = { attributes = {
@ -125,6 +125,7 @@ class User
when :attempts then :integer when :attempts then :integer
when :action then :string when :action then :string
when :credit_card then :string when :credit_card then :string
when :uuid then :uuid
end end
Column.new(attribute, column_type, limit) Column.new(attribute, column_type, limit)
end end