form-select 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +11 -1
- data/lib/form-select.rb +0 -1
- data/lib/form_select/model.rb +3 -1
- data/lib/form_select/version.rb +1 -1
- metadata +3 -5
- data/app/controllers/form-select/application_controller.rb +0 -7
- data/lib/form_select/engine.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fb208f140fe8d77254a5790e69a026c1ed0143df103e17268678dd056372fae6
|
4
|
+
data.tar.gz: 0f203c9571eefd2b5beb112630c0c0b982f1d46a321386691caf5c36220249a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab5d849bb5730e850a3f3341d6e4e4c14ee07735d5a09570e61852cbe415f90558ab5e02df9eb452cdc92a6c60c35b3a4d06a54e64b05e01aac75da7146a389
|
7
|
+
data.tar.gz: b99797d927a45b71ba6965d17510ffc876ac813f59c1992fbafb7de836c4aae907e608144c9d01b67da88aed4883ecd339d489eb6a259ab889192019e7b69e07
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# FormSelect
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/rails-engine/form-select.svg?branch=master)](https://travis-ci.org/rails-engine/form-select)
|
4
|
+
|
3
5
|
A simple improve for Rails form select helper.
|
4
6
|
|
5
7
|
We need use `form.select ::category_id, Category.collect { |record| [record.name, record.id] }` in so many case.
|
@@ -23,7 +25,8 @@ end
|
|
23
25
|
class User
|
24
26
|
form_select :login, field: [:login, :to_param], scope: -> { order("id desc") }
|
25
27
|
form_select :email
|
26
|
-
form_select :email_value, field:
|
28
|
+
form_select :email_value, field: :email
|
29
|
+
form_select :city, field: :city, scope: -> { where("city is not null").select(:city).distinct }
|
27
30
|
|
28
31
|
def to_param
|
29
32
|
login.downcase
|
@@ -48,6 +51,8 @@ irb> User.email_options
|
|
48
51
|
=> [["jason@gmail.com", 10], ["mike@foo.com", 11], ["foo@bar.com", 12]]
|
49
52
|
irb> User.email_value_options
|
50
53
|
=> [["jason@gmail.com", "jason@gmail.com"], ["mike@foo.com", "mike@foo.com"], ["foo@bar.com", "foo@bar.com"]]
|
54
|
+
irb> User.city_options
|
55
|
+
=> [["NewYork", "NewYork"], ["San Francisco", "San Francisco"], ["Chicago", "Chicago"]]
|
51
56
|
irb> Post.author_options
|
52
57
|
=> [["Jason", "Jason"], ["Mike", "Mike"], ["Foor", "Foo"]]
|
53
58
|
```
|
@@ -66,6 +71,11 @@ So you can easy use it in Rails form:
|
|
66
71
|
<%= form.select :user_id, User.email_options %>
|
67
72
|
</div>
|
68
73
|
|
74
|
+
<div class="field">
|
75
|
+
<%= form.label :city %>
|
76
|
+
<%= form.select :city, User.city_options %>
|
77
|
+
</div>
|
78
|
+
|
69
79
|
<div class="field">
|
70
80
|
<%= form.label :category_id %>
|
71
81
|
<%= form.select :category_id, Category.name_options %>
|
data/lib/form-select.rb
CHANGED
data/lib/form_select/model.rb
CHANGED
@@ -14,10 +14,12 @@ module FormSelect
|
|
14
14
|
#
|
15
15
|
# class User < ApplicationRecord
|
16
16
|
# form_select :name, scope: -> { order("name asc") }
|
17
|
-
#
|
17
|
+
# form_select :name_value, field: :name, scope: -> { order("name asc") }
|
18
18
|
# form_select :email, field: [:name, :email], scope: -> { where(status: :active).order("id desc") }
|
19
|
+
# form_select :city, field: :city, scope: -> { where("city is not null").select(:city).distinct }
|
19
20
|
# end
|
20
21
|
#
|
22
|
+
#
|
21
23
|
# <div class="field">
|
22
24
|
# <%= form.label :user_id %>
|
23
25
|
# <%= form.select :user_id, User.name_options %>
|
data/lib/form_select/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form-select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -48,10 +48,8 @@ files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
-
- app/controllers/form-select/application_controller.rb
|
52
51
|
- config/routes.rb
|
53
52
|
- lib/form-select.rb
|
54
|
-
- lib/form_select/engine.rb
|
55
53
|
- lib/form_select/model.rb
|
56
54
|
- lib/form_select/version.rb
|
57
55
|
homepage: https://github.com/rails-engine/form-select
|
@@ -74,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
72
|
version: '0'
|
75
73
|
requirements: []
|
76
74
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.6
|
75
|
+
rubygems_version: 2.7.6
|
78
76
|
signing_key:
|
79
77
|
specification_version: 4
|
80
78
|
summary: Helper of form select options
|