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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 61a7e843bb09d1878d151673b4a408f84a2b9c95
4
- data.tar.gz: fbe4ea1384d8b012e9f38a21d6be472f22a55e38
2
+ SHA256:
3
+ metadata.gz: fb208f140fe8d77254a5790e69a026c1ed0143df103e17268678dd056372fae6
4
+ data.tar.gz: 0f203c9571eefd2b5beb112630c0c0b982f1d46a321386691caf5c36220249a4
5
5
  SHA512:
6
- metadata.gz: 195e4b77f0c78c1d25fd76e613170b8cc3a91c5b3e817c90c9119158bb1f0452fbc973f5e56e603d5c5c11a31bebab2a87d96a7d03a58828370faa2b8700556b
7
- data.tar.gz: f09907dc90dddba6393d7fe69edb702def9ec3eab75f988cd38a54510017730d01d7d676f759bb022e8708ae90e818f01d76ac225ea273c6a9a7aa228dad43f8
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: [:email]
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 %>
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "./form_select/version"
4
- require_relative "./form_select/engine"
5
4
  require_relative "./form_select/model"
6
5
 
7
6
  module FormSelect
@@ -14,10 +14,12 @@ module FormSelect
14
14
  #
15
15
  # class User < ApplicationRecord
16
16
  # form_select :name, scope: -> { order("name asc") }
17
- # form_select :name_value, field: [:name], scope: -> { order("name asc") }
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 %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FormSelect
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
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.2.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-22 00:00:00.000000000 Z
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.14
75
+ rubygems_version: 2.7.6
78
76
  signing_key:
79
77
  specification_version: 4
80
78
  summary: Helper of form select options
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FormSelect
4
- class ApplicationController < ActionController::Base
5
- protect_from_forgery with: :exception
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FormSelect
4
- class Engine < ::Rails::Engine
5
- isolate_namespace FormSelect
6
- end
7
- end