bootstrap_form 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +21 -8
  3. data/.gitignore +4 -2
  4. data/.rubocop.yml +2 -1
  5. data/.yarnrc +5 -0
  6. data/CHANGELOG.md +11 -3
  7. data/CONTRIBUTING.md +101 -14
  8. data/Dangerfile +4 -4
  9. data/Dockerfile +5 -5
  10. data/Gemfile +5 -21
  11. data/README.md +68 -21
  12. data/RELEASING.md +12 -1
  13. data/Rakefile +7 -6
  14. data/bootstrap_form.gemspec +6 -8
  15. data/docker-compose.yml +6 -24
  16. data/gemfiles/6.0.gemfile +1 -1
  17. data/gemfiles/6.1.gemfile +1 -1
  18. data/gemfiles/7.0.gemfile +2 -3
  19. data/gemfiles/common.gemfile +28 -0
  20. data/gemfiles/edge.gemfile +3 -2
  21. data/lib/bootstrap_form/components/labels.rb +3 -9
  22. data/lib/bootstrap_form/components/validation.rb +36 -19
  23. data/lib/bootstrap_form/form_builder.rb +3 -0
  24. data/lib/bootstrap_form/form_group.rb +9 -6
  25. data/lib/bootstrap_form/form_group_builder.rb +10 -7
  26. data/lib/bootstrap_form/helpers/bootstrap.rb +7 -8
  27. data/lib/bootstrap_form/helpers/field.rb +26 -0
  28. data/lib/bootstrap_form/helpers.rb +1 -0
  29. data/lib/bootstrap_form/inputs/check_box.rb +22 -6
  30. data/lib/bootstrap_form/inputs/radio_button.rb +3 -3
  31. data/lib/bootstrap_form/version.rb +2 -1
  32. data/lib/bootstrap_form.rb +1 -1
  33. metadata +14 -146
  34. data/demo/.postcssrc.yml +0 -3
  35. data/demo/.ruby-version +0 -1
  36. data/demo/Gemfile +0 -80
  37. data/demo/Gemfile.lock +0 -261
  38. data/demo/Procfile.dev +0 -2
  39. data/demo/README.md +0 -17
  40. data/demo/Rakefile +0 -6
  41. data/demo/app/assets/builds/.keep +0 -0
  42. data/demo/app/assets/builds/application.js.LICENSE.txt +0 -9
  43. data/demo/app/assets/config/manifest.js +0 -2
  44. data/demo/app/assets/stylesheets/actiontext.css +0 -31
  45. data/demo/app/assets/stylesheets/actiontext.scss +0 -38
  46. data/demo/app/assets/stylesheets/application.scss +0 -1
  47. data/demo/app/controllers/application_controller.rb +0 -2
  48. data/demo/app/controllers/bootstrap_controller.rb +0 -29
  49. data/demo/app/controllers/users_controller.rb +0 -9
  50. data/demo/app/helpers/bootstrap_helper.rb +0 -27
  51. data/demo/app/javascript/application.js +0 -3
  52. data/demo/app/javascript/channels/consumer.js +0 -6
  53. data/demo/app/javascript/channels/index.js +0 -5
  54. data/demo/app/javascript/packs/application.js +0 -11
  55. data/demo/app/models/address.rb +0 -3
  56. data/demo/app/models/application_record.rb +0 -3
  57. data/demo/app/models/faux_user.rb +0 -9
  58. data/demo/app/models/skill.rb +0 -15
  59. data/demo/app/models/super_user.rb +0 -2
  60. data/demo/app/models/user.rb +0 -25
  61. data/demo/app/views/active_storage/blobs/_blob.html.erb +0 -14
  62. data/demo/app/views/bootstrap/form.html.erb +0 -67
  63. data/demo/app/views/layouts/action_text/contents/_content.html.erb +0 -3
  64. data/demo/app/views/layouts/application.html.erb +0 -76
  65. data/demo/bin/bundle +0 -3
  66. data/demo/bin/dev +0 -9
  67. data/demo/bin/rails +0 -4
  68. data/demo/bin/rake +0 -4
  69. data/demo/bin/setup +0 -36
  70. data/demo/bin/update +0 -31
  71. data/demo/bin/webpack +0 -15
  72. data/demo/bin/webpack-dev-server +0 -15
  73. data/demo/bin/yarn +0 -11
  74. data/demo/config/application.rb +0 -21
  75. data/demo/config/boot.rb +0 -5
  76. data/demo/config/database.yml +0 -21
  77. data/demo/config/environment.rb +0 -5
  78. data/demo/config/environments/development.rb +0 -60
  79. data/demo/config/environments/production.rb +0 -48
  80. data/demo/config/environments/test.rb +0 -46
  81. data/demo/config/initializers/application_controller_renderer.rb +0 -8
  82. data/demo/config/initializers/backtrace_silencers.rb +0 -7
  83. data/demo/config/initializers/cookies_serializer.rb +0 -5
  84. data/demo/config/initializers/filter_parameter_logging.rb +0 -4
  85. data/demo/config/initializers/inflections.rb +0 -16
  86. data/demo/config/initializers/mime_types.rb +0 -4
  87. data/demo/config/initializers/wrap_parameters.rb +0 -14
  88. data/demo/config/locales/en.yml +0 -33
  89. data/demo/config/puma.rb +0 -56
  90. data/demo/config/routes.rb +0 -6
  91. data/demo/config/spring.rb +0 -6
  92. data/demo/config/storage.yml +0 -35
  93. data/demo/config/webpack/development.js +0 -5
  94. data/demo/config/webpack/environment.js +0 -3
  95. data/demo/config/webpack/production.js +0 -5
  96. data/demo/config/webpack/test.js +0 -5
  97. data/demo/config/webpacker.yml +0 -92
  98. data/demo/config.ru +0 -5
  99. data/demo/db/schema.rb +0 -84
  100. data/demo/doc/screenshots/bootstrap/index/00_horizontal_form.png +0 -0
  101. data/demo/doc/screenshots/bootstrap/index/01_with_validation_error.png +0 -0
  102. data/demo/doc/screenshots/bootstrap/index/02_inline_form.png +0 -0
  103. data/demo/doc/screenshots/bootstrap/index/03_simple_action_text_example.png +0 -0
  104. data/demo/doc/screenshots/bootstrap/index/04_floating_labels.png +0 -0
  105. data/demo/doc/screenshots/bootstrap/readme/00_example.png +0 -0
  106. data/demo/doc/screenshots/bootstrap/readme/01_example.png +0 -0
  107. data/demo/doc/screenshots/bootstrap/readme/02_example.png +0 -0
  108. data/demo/doc/screenshots/bootstrap/readme/03_example.png +0 -0
  109. data/demo/doc/screenshots/bootstrap/readme/04_example.png +0 -0
  110. data/demo/doc/screenshots/bootstrap/readme/05_example.png +0 -0
  111. data/demo/doc/screenshots/bootstrap/readme/06_example.png +0 -0
  112. data/demo/doc/screenshots/bootstrap/readme/07_example.png +0 -0
  113. data/demo/doc/screenshots/bootstrap/readme/08_example.png +0 -0
  114. data/demo/doc/screenshots/bootstrap/readme/09_example.png +0 -0
  115. data/demo/doc/screenshots/bootstrap/readme/10_example.png +0 -0
  116. data/demo/doc/screenshots/bootstrap/readme/11_example.png +0 -0
  117. data/demo/doc/screenshots/bootstrap/readme/12_example.png +0 -0
  118. data/demo/doc/screenshots/bootstrap/readme/13_example.png +0 -0
  119. data/demo/doc/screenshots/bootstrap/readme/14_example.png +0 -0
  120. data/demo/doc/screenshots/bootstrap/readme/15_example.png +0 -0
  121. data/demo/doc/screenshots/bootstrap/readme/16_example.png +0 -0
  122. data/demo/doc/screenshots/bootstrap/readme/17_example.png +0 -0
  123. data/demo/doc/screenshots/bootstrap/readme/18_example.png +0 -0
  124. data/demo/doc/screenshots/bootstrap/readme/19_example.png +0 -0
  125. data/demo/doc/screenshots/bootstrap/readme/20_example.png +0 -0
  126. data/demo/doc/screenshots/bootstrap/readme/21_example.png +0 -0
  127. data/demo/doc/screenshots/bootstrap/readme/22_example.png +0 -0
  128. data/demo/doc/screenshots/bootstrap/readme/23_example.png +0 -0
  129. data/demo/doc/screenshots/bootstrap/readme/24_example.png +0 -0
  130. data/demo/doc/screenshots/bootstrap/readme/25_example.png +0 -0
  131. data/demo/doc/screenshots/bootstrap/readme/26_example.png +0 -0
  132. data/demo/doc/screenshots/bootstrap/readme/27_example.png +0 -0
  133. data/demo/doc/screenshots/bootstrap/readme/28_example.png +0 -0
  134. data/demo/doc/screenshots/bootstrap/readme/29_example.png +0 -0
  135. data/demo/doc/screenshots/bootstrap/readme/30_example.png +0 -0
  136. data/demo/doc/screenshots/bootstrap/readme/31_example.png +0 -0
  137. data/demo/doc/screenshots/bootstrap/readme/32_example.png +0 -0
  138. data/demo/doc/screenshots/bootstrap/readme/33_example.png +0 -0
  139. data/demo/doc/screenshots/bootstrap/readme/34_example.png +0 -0
  140. data/demo/doc/screenshots/bootstrap/readme/35_example.png +0 -0
  141. data/demo/doc/screenshots/bootstrap/readme/36_example.png +0 -0
  142. data/demo/doc/screenshots/bootstrap/readme/37_example.png +0 -0
  143. data/demo/doc/screenshots/bootstrap/readme/38_example.png +0 -0
  144. data/demo/doc/screenshots/bootstrap/readme/39_example.png +0 -0
  145. data/demo/doc/screenshots/bootstrap/readme/40_example.png +0 -0
  146. data/demo/doc/screenshots/bootstrap/readme/41_example.png +0 -0
  147. data/demo/doc/screenshots/bootstrap/readme/42_example.png +0 -0
  148. data/demo/doc/screenshots/bootstrap/readme/43_example.png +0 -0
  149. data/demo/doc/screenshots/bootstrap/readme/44_example.png +0 -0
  150. data/demo/doc/screenshots/bootstrap/readme/45_example.png +0 -0
  151. data/demo/doc/screenshots/bootstrap/readme/46_example.png +0 -0
  152. data/demo/doc/screenshots/bootstrap/readme/47_example.png +0 -0
  153. data/demo/doc/screenshots/bootstrap/readme/48_example.png +0 -0
  154. data/demo/doc/screenshots/bootstrap/readme/49_example.png +0 -0
  155. data/demo/doc/screenshots/bootstrap/readme/50_example.png +0 -0
  156. data/demo/log/.keep +0 -0
  157. data/demo/package.json +0 -21
  158. data/demo/public/favicon.ico +0 -0
  159. data/demo/test/application_system_test_case.rb +0 -8
  160. data/demo/test/controllers/bootstrap_controller_test.rb +0 -8
  161. data/demo/test/controllers/users_controller_test.rb +0 -13
  162. data/demo/test/fixtures/action_text/rich_texts.yml +0 -4
  163. data/demo/test/fixtures/users.yml +0 -2
  164. data/demo/test/system/bootstrap_test.rb +0 -84
  165. data/demo/test/test_helper.rb +0 -10
  166. data/demo/webpack.config.js +0 -20
  167. data/demo/yarn.lock +0 -7176
  168. data/gemfiles/5.2.gemfile +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75c715774dfcbad34c15dbd54c3a14da015c4e67805c0a1adfbfd36ff0f0d27b
4
- data.tar.gz: f1a3c95a6cd6f2012c8062f5e3c3f8b680cb17292141443d8465625a552d1e5b
3
+ metadata.gz: 3d296af534429e0065b8f5aef6254dd12455e6317fd36f684b060b3c425c03e8
4
+ data.tar.gz: aa02bc3031975302dbe4d556a1fcaa6751e2b4cbb961e737fa23b80516904ea2
5
5
  SHA512:
6
- metadata.gz: 75107dba8802198d3685161d292ae40e28e9e83acd688c7779a5bf9eade665bdad236c7f64aeac906872a9e751f77ad98a6e24bda27334a8472bb5ec11855906
7
- data.tar.gz: 0c30626a9bde0725bc7ca12713bc9d9acc588832e450752a4142c3a9bc63a47aec9bbdf016a1973ea173153ae700c88f4e0be820ca75c0047ced7cd5d8daa0dc
6
+ metadata.gz: 0a402ef41606092aa37ec284382f754aea85d73dfc16b8b065ea130c6d47910d061afac644a0b0d38f1269f0c53caa2f987c8b5d4ce9dfa6105811919a40bc8f
7
+ data.tar.gz: 546e5dbb15379578c5f06a4d6d40a362bd08d9dc4049cd4a7140cc7b29f459bfc8f914d8e114125d398be8b323102d4912653d589e008441eb288dda71fb0ebd
@@ -7,13 +7,15 @@ on:
7
7
  jobs:
8
8
  Lint:
9
9
  runs-on: ubuntu-latest
10
+ env:
11
+ BUNDLE_GEMFILE: gemfiles/6.0.gemfile
10
12
  steps:
11
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v3
12
14
  with:
13
15
  fetch-depth: 0
14
16
  - uses: ruby/setup-ruby@v1
15
17
  with:
16
- ruby-version: 2.7
18
+ ruby-version: 3.0.6
17
19
  bundler-cache: true
18
20
  # Disabled since it requires access not granted by GitHub Actions for PRs
19
21
  # - name: Danger
@@ -23,22 +25,21 @@ jobs:
23
25
  # run: |
24
26
  # bundle exec danger
25
27
  - name: Rubocop
26
- run: bundle exec rubocop --auto-correct
28
+ run: bundle exec rubocop --autocorrect
27
29
  Test:
28
30
  runs-on: ubuntu-latest
29
31
  strategy:
30
32
  fail-fast: false
31
33
  matrix:
32
- ruby-version: [ '3.1', '3.0', '2.7' ]
33
- gemfile: [ '7.0', '6.1', '6.0', '5.2', 'edge' ]
34
+ ruby-version: [ '3.2', '3.1', '3.0' ]
35
+ gemfile: [ '7.0', '6.1', '6.0', 'edge' ]
34
36
  exclude:
37
+ - { ruby-version: '3.2', gemfile: "6.0" }
35
38
  - { ruby-version: '3.1', gemfile: "6.0" }
36
- - { ruby-version: '3.1', gemfile: "5.2" }
37
- - { ruby-version: '3.0', gemfile: "5.2" }
38
39
  env:
39
40
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
40
41
  steps:
41
- - uses: actions/checkout@v2
42
+ - uses: actions/checkout@v3
42
43
  - name: Set up Ruby
43
44
  uses: ruby/setup-ruby@v1
44
45
  with:
@@ -46,3 +47,15 @@ jobs:
46
47
  bundler-cache: true
47
48
  - name: Run tests
48
49
  run: bundle exec rake test
50
+ Demo:
51
+ runs-on: ubuntu-latest
52
+ steps:
53
+ - uses: actions/checkout@v3
54
+ - name: Set up Ruby
55
+ uses: ruby/setup-ruby@v1
56
+ with:
57
+ working-directory: demo
58
+ bundler-cache: true
59
+ - name: Run tests
60
+ working-directory: demo
61
+ run: bundle exec rake test:all
data/.gitignore CHANGED
@@ -16,7 +16,9 @@ gemfiles/*.lock
16
16
  /.ruby-version
17
17
  Vagrantfile
18
18
  .vagrant
19
- .yarnrc
19
+ **/.yarn/**/cache
20
+ **/.yarn/install-state.gz
21
+ **/.yarn/unplugged
20
22
 
21
23
  # For the demo app.
22
24
 
@@ -25,7 +27,7 @@ demo/storage/*
25
27
  !demo/storage/.keep
26
28
 
27
29
  demo/public/assets
28
- .byebug_history
30
+ **/.byebug_history
29
31
 
30
32
  # Ignore master key for decrypting credentials and more.
31
33
  demo/config/master.key
data/.rubocop.yml CHANGED
@@ -5,7 +5,8 @@ require:
5
5
  AllCops:
6
6
  DisplayCopNames: true
7
7
  DisplayStyleGuide: true
8
- TargetRubyVersion: 2.7
8
+ TargetRubyVersion: 3.0
9
+ TargetRailsVersion: 6.0
9
10
  NewCops: enable
10
11
  Exclude:
11
12
  - bin/*
data/.yarnrc ADDED
@@ -0,0 +1,5 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ lastUpdateCheck 1681870014941
data/CHANGELOG.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # Change Log
2
2
 
3
- ## Apology
3
+ You can find recent releases with docs in GitHub:
4
4
 
5
- The tooling to support our old way of doing the change log doesn't work anymore, and we don't have a better solution, so this change log has become unreliable since version 4.5.0. Please refer to the commit history if you need to debug changes.
5
+ https://github.com/bootstrap-ruby/bootstrap_form/releases
6
6
 
7
+ ## Diffs
7
8
 
8
- - [Pending Release](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.1.0...HEAD)
9
+ - [Pending Release](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.2.0...HEAD)
10
+ - [5.2.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.1.0...v5.2.0)
11
+ [Issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2022-06-25T17%3A22..2023-05-20T23%3A59)
9
12
  - [5.1.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.0.0...v5.1.0)
13
+ [Issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2021-11-12T05%3A58..2022-06-25T17%3A22)
10
14
  - [5.0.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.5.0...v5.0.0)
11
15
  - [4.5.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.4.0...v4.5.0)
12
16
  - [4.4.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.3.0...v4.4.0)
@@ -23,6 +27,10 @@ The tooling to support our old way of doing the change log doesn't work anymore,
23
27
  - [2.5.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.4.0...v2.5.0)
24
28
  - [2.4.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.3.0...v2.4.0)
25
29
 
30
+ ## Older releases
31
+
32
+ The tooling to support our old way of doing the change log doesn't work anymore, and we don't have a better solution, so this change log has become unreliable since version 4.5.0. Please refer to the commit history if you need to debug changes.
33
+
26
34
  ## [Pending Release][]
27
35
 
28
36
  ### Breaking changes
data/CONTRIBUTING.md CHANGED
@@ -46,11 +46,11 @@ You may find the [demo application](#the-demo-application) useful for developmen
46
46
 
47
47
  ### 6. Make a pull request
48
48
 
49
- - If you've never made a pull request (PR) before, read this: https://help.github.com/articles/about-pull-requests/.
49
+ - If you've never made a pull request (PR) before, read [this](https://help.github.com/articles/about-pull-requests/).
50
50
  - If your PR fixes an issues, be sure to put "Fixes #nnn" in the description of the PR (where `nnn` is the issue number). Github will automatically close the issue when the PR is merged.
51
51
  - When the PR is submitted, check if Travis CI ran all the tests successfully, and didn't raise any issues.
52
52
 
53
- ### 7. Done!
53
+ ### 7. Done
54
54
 
55
55
  Somebody will shortly review your pull request and if everything is good, it will be
56
56
  merged into the main branch. Eventually the gem will be published with your changes.
@@ -74,6 +74,59 @@ The Ruby on Rails support policy is [here](https://guides.rubyonrails.org/mainte
74
74
 
75
75
  ### Developing with Docker
76
76
 
77
+ This repository offers experimental support support for a couple of ways to develop using Docker, if you're interested:
78
+
79
+ - Using `docker-compose`. This way is less tested, and is an attempt to make the Docker container a more complete environment where you can conveniently develop and release the gem.
80
+ - Using just a simple Dockerfile. This way works for simple testing, but doesn't make it easy to release the gem, among other things.
81
+
82
+ Docker is _not_ requied to work on this gem.
83
+
84
+ #### Using `docker-compose`
85
+
86
+ The `docker-compose` approach should link to enough of your networking configuration that you can release the gem.
87
+ However, you have to do some of the configuration yourself, because it's dependent on your host operating system.
88
+ You can run a shell in a Docker container that pretty much should behave like a Debian distribution with:
89
+
90
+ ```bash
91
+ docker-compose run --service-ports shell
92
+ ```
93
+
94
+ (`--service-ports` exposes port 3000 so you can browse to the demo app on `localhost:3000`. If you just want to run a on-off command, or run the test suite, leave off the `--service-ports`.)
95
+
96
+ The following instructions work for an Ubuntu host, and will probably work for other common Linux distributions.
97
+
98
+ Add a `docker-compose.override.yml` in the local directory, that looks like this:
99
+
100
+ ```docker-compose.yml
101
+ version: '3.3'
102
+
103
+ # https://blog.giovannidemizio.eu/2021/05/24/how-to-set-user-and-group-in-docker-compose/
104
+
105
+ services:
106
+ shell:
107
+ # You have to set the user and group for this process, because you're going to be
108
+ # creating all kinds of files from inside the container, that need to persist
109
+ # outside the container.
110
+ # Change `1000:1000` to the user and default group of your laptop user.
111
+ user: 1000:1000
112
+ volumes:
113
+ - /etc/passwd:/etc/passwd:ro
114
+ - ~/.gem/credentials:/app/.gem/credentials:ro
115
+ # $HOME here is your host computer's `~`, e.g. `/home/reid`.
116
+ # `ssh` explicitly looks for its config in the home directory from `/etc/passwd`,
117
+ # so the target for this has to look like your home directory on the host.
118
+ - ~/.ssh:${HOME}/.ssh:ro
119
+ - ${SSH_AUTH_SOCK}:/ssh-agent
120
+ environment:
121
+ - SSH_AUTH_SOCK=/ssh-agent
122
+ ```
123
+
124
+ You may have to change the `1000:1000` to the user and group IDs of your laptop. You may also have to change the `version` parameter to match the version of the `docker-compose.yml` file.
125
+
126
+ Adapting the above `docker-compose.override.yml` for MacOS should be relatively straight-forward. Windows users, I'm afraid you're on your own.
127
+
128
+ #### Simple Dockerfile
129
+
77
130
  This repository includes a `Dockerfile` to build an image with the minimum `bootstrap_form`-supported Ruby environment. To build the image:
78
131
 
79
132
  ```bash
@@ -85,7 +138,7 @@ This builds an image called `bootstrap_form`. You can change that to any tag you
85
138
  If you want to use a different Ruby version, or a smaller Linux distribution (although the distro may be missing tools you need):
86
139
 
87
140
  ```bash
88
- docker build --build-arg "RUBY_VERSION=2.7" --build-arg "DISTRO=slim-buster" --tag bootstrap_form .
141
+ docker build --build-arg "RUBY_VERSION=3.0" --build-arg "DISTRO=slim-buster" --tag bootstrap_form .
89
142
  ```
90
143
 
91
144
  Then run the container you built with the shell, and create the bundle:
@@ -99,6 +152,12 @@ You can run tests in the container as normal, with `rake test`.
99
152
 
100
153
  (Some of that command line is need for Linux hosts, to run the container as the current user.)
101
154
 
155
+ One of the disadvantages of this approach is that you can't release the gem from here, because the Docker container doesn't have access to your SSH credentials, or the right user name, or perhaps other things needed to release a gem. But for simple testing, it works.
156
+
157
+ #### Troubleshooting Docker
158
+
159
+ - With the above configuration, the gems are kept in `vendor/bundle` on your hosts, which is `$GEM_HOME` or `/app/vendor/bundle` in the running Docker container. If you're having permission problems when switching versions of Ruby or Rails, you can try `sudo rm -rf vendor/bundle` on the host, then run `BUNDLE_GEMFILES=gemfiles/7.0.gemfile bundle update` in the Docker container to re-install all the gems with the right permissions.
160
+
102
161
  ### The Demo Application
103
162
 
104
163
  There is a demo app in this repository. It shows some of the features of `bootstrap_form`, and provides a base on which to build ad-hoc testing, if you need it.
@@ -110,8 +169,7 @@ To run the demo app, set up the database and run the server:
110
169
  cd demo
111
170
  bundle
112
171
  rails db:setup
113
- yarn build --watch &
114
- rails s -b 0.0.0.0
172
+ dev
115
173
  ```
116
174
 
117
175
  To run the demo app in the Docker container:
@@ -119,21 +177,32 @@ To run the demo app in the Docker container:
119
177
  ```bash
120
178
  docker run --volume "$PWD:/app" --user $UID:`grep ^$USERNAME /etc/passwd | cut -d: -f4` -p 3000:3000 -it bootstrap_form /bin/bash
121
179
  cd demo
122
- export BUNDLE_GEMFILE=../gemfiles/7.0.gemfile
180
+ bundle
123
181
  rails db:setup
124
- yarn build --watch &
125
- rails s -b 0.0.0.0
182
+ dev
126
183
  ```
127
184
 
128
- The app doesn't appear to find the source map, or perhaps it isn't being generated. In the Rails log you will see messages similar to:
185
+ You'll see errors in the browser console about duplicate ids. This is expected, since the demo app has many forms with the same fields in them. Something we can fix in the future, perhaps.
129
186
 
130
- ```bash
131
- ActionController::RoutingError (No route matches [GET] "/assets/application.js-c6c0edbd68f05cffd0e2495198bfbc4bf42be8a11b76eecbfade30a8036b6b87.map")
187
+ To use other supported versions of Rails, you will need to create a `Gemfile` for the Rails version. Then, change the `export BUNDLE_GEMFILE...` line to your gem file. Finally, figure out how to include the assets.
188
+
189
+ If you need to run the Rails server separately, for example, to debug the server, you _must_ run it like this:
190
+
191
+ ```sh
192
+ bundle exec rails s -b 0.0.0.0
132
193
  ```
133
194
 
134
- But this doesn't seem to affect how the app runs.
195
+ If you run just `rails` or even `bin/rails`, the `sprockets-rails` gem won't load and you'll either get error messages, or the assets won't be available to the demo app. At the moment it's a mystery why. PRs to fix this are welcome.
135
196
 
136
- To use other supported versions of Rails, you will need to create a `Gemfile` for the Rails version. Then, change the `export BUNDLE_GEMFILE...` line to your gem file. Finally, figure out how to include the assets.
197
+ Please try to keep the checked-in `.ruby-version` set to the oldest supported version of Ruby. You're welcome and encouraged to try the demo app with other Ruby versions. Just don't check in the `.ruby-version` to GitHub.
198
+
199
+ For the record, the demo app is set up as if the Rails app had been created with:
200
+
201
+ ```sh
202
+ rails new --skip-hotwire -d sqlite --edge -j esbuild -c bootstrap .
203
+ ```
204
+
205
+ This means it's using `esbuild` to pre-process the JavaScript and (S)CSS, and that it's using [`jsbunding-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails) to put the assets in `app/assets/builds`, before the Sprockets assets pipeline serves them in development, or pre-compiles them in production.
137
206
 
138
207
  ## Documentation Contributions
139
208
 
@@ -147,7 +216,7 @@ We are an entirely volunteer project. Sometimes it's hard for people to find the
147
216
 
148
217
  ---
149
218
 
150
- Thanks to all the great contributors over the years: https://github.com/bootstrap-ruby/bootstrap_form/graphs/contributors
219
+ Thanks to all the [great contributors](https://github.com/bootstrap-ruby/bootstrap_form/graphs/contributors) over the years.
151
220
 
152
221
  ## Troubleshooting
153
222
 
@@ -162,3 +231,21 @@ cd demo
162
231
  rails db:setup # create the databases from `schema.rb`
163
232
  rails db:migrate # add the new tables and create a new `schema.rb`
164
233
  ```
234
+
235
+ ### RuboCop
236
+
237
+ When you push a branch, RuboCop checks may fail, but locally you can't reproduce the failure. This may be because you're using a different version of RuboCop locally. When you push, the RuboCop tests use the currently available version of RuboCop. If you've been working on the branch for a while, it's likely you have a `Gemfile.lock` that specifies an older version of RuboCop.
238
+
239
+ The first thing to try is to update your `Gemfile.lock` locally:
240
+
241
+ ```bash
242
+ bundle update
243
+ ```
244
+
245
+ Or, if you really want to minimize your work:
246
+
247
+ ```bash
248
+ bundle update --conservative rubocop
249
+ ```
250
+
251
+ This should enable you to reproduce the RuboCop failures locally, and then you can fix them.
data/Dangerfile CHANGED
@@ -19,8 +19,8 @@ has_changelog_changes = git.modified_files.include?("CHANGELOG.md")
19
19
  # You've made changes to lib, but didn't write any tests?
20
20
  # ------------------------------------------------------------------------------
21
21
  if has_lib_changes && !has_test_changes
22
- warn("There are code changes, but no corresponding tests. "\
23
- "Please include tests if this PR introduces any modifications in "\
22
+ warn("There are code changes, but no corresponding tests. " \
23
+ "Please include tests if this PR introduces any modifications in " \
24
24
  "#{project_name}'s behavior.",
25
25
  sticky: false)
26
26
  end
@@ -36,8 +36,8 @@ if !has_changelog_changes && has_lib_changes
36
36
  * [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
37
37
  ```
38
38
  MARKDOWN
39
- warn("Please update CHANGELOG.md with a description of your changes. "\
40
- "If this PR is not a user-facing change (e.g. just refactoring), "\
39
+ warn("Please update CHANGELOG.md with a description of your changes. " \
40
+ "If this PR is not a user-facing change (e.g. just refactoring), " \
41
41
  "you can disregard this.", sticky: false)
42
42
  end
43
43
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- ARG RUBY_VERSION=2.7
1
+ ARG RUBY_VERSION=3.0
2
2
  ARG DISTRO=bullseye
3
3
 
4
4
  FROM ruby:$RUBY_VERSION-$DISTRO
@@ -13,9 +13,9 @@ ENV PATH ./bin:$GEM_HOME/bin:$PATH
13
13
  RUN (echo 'docker'; echo 'docker') | passwd root
14
14
 
15
15
  # Yarn installs nodejs.
16
- RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
17
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
18
- apt update -y -q && \
19
- apt install -y -q yarn sqlite3
16
+ # Rails wants a newer version of node that we get with the Debian distro.
17
+ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs
18
+ RUN corepack enable && corepack prepare yarn@stable --activate
19
+ RUN apt install -y -q yarn sqlite3
20
20
 
21
21
  EXPOSE 3000
data/Gemfile CHANGED
@@ -1,23 +1,7 @@
1
- source "http://rubygems.org"
1
+ gems = "#{__dir__}/gemfiles/common.gemfile"
2
+ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
2
3
 
3
- gemspec path: __dir__
4
+ require "#{__dir__}/lib/bootstrap_form/version"
4
5
 
5
- # To test with different Rails versions, use the files in `./gemfiles`
6
-
7
- group :development do
8
- gem "htmlbeautifier"
9
- gem "rubocop-performance", require: false
10
- gem "rubocop-rails", require: false
11
- gem "webpacker"
12
- end
13
-
14
- group :test do
15
- gem "diffy"
16
- gem "equivalent-xml"
17
- gem "mocha"
18
- gem "sqlite3"
19
- end
20
-
21
- group :ci do
22
- gem "danger"
23
- end
6
+ gem "rails", BootstrapForm::REQUIRED_RAILS_VERSION
7
+ gem "sprockets-rails", require: "sprockets/railtie"
data/README.md CHANGED
@@ -25,8 +25,8 @@ Some other nice things that `bootstrap_form` does for you are:
25
25
 
26
26
  `bootstrap_form` supports at a minimum the currently supported versions of Ruby and Rails:
27
27
 
28
- * Ruby 2.5+
29
- * Rails 5.2+
28
+ * Ruby 3.0+ (https://www.ruby-lang.org/en/downloads/branches/)
29
+ * Rails 6.0+ (https://guides.rubyonrails.org/maintenance_policy.html)
30
30
  * Bootstrap 5.0+
31
31
 
32
32
  ## Installation
@@ -42,7 +42,7 @@ And follow the remaining instructions in the [official bootstrap installation gu
42
42
  Add the `bootstrap_form` gem to your `Gemfile`:
43
43
 
44
44
  ```ruby
45
- gem "bootstrap_form", "~> 5.1"
45
+ gem "bootstrap_form", "~> 5.2"
46
46
  ```
47
47
 
48
48
  Then:
@@ -84,7 +84,7 @@ This generates the following HTML:
84
84
  <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
85
85
  <div class="mb-3">
86
86
  <label class="form-label required" for="user_email">Email</label>
87
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
87
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
88
88
  </div>
89
89
  <div class="mb-3">
90
90
  <label class="form-label" for="user_password">Password</label>
@@ -145,7 +145,7 @@ This generates:
145
145
  <form accept-charset="UTF-8" action="/users" method="post">
146
146
  <div class="mb-3">
147
147
  <label class="form-label required" for="user_email">Email</label>
148
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
148
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
149
149
  </div>
150
150
  <div class="mb-3">
151
151
  <label class="form-label" for="user_password">Password</label>
@@ -278,7 +278,7 @@ This generates:
278
278
  ```html
279
279
  <div class="mb-3">
280
280
  <label class="form-label custom-class required" for="user_email">Email</label>
281
- <input class="form-control" id="user_email" name="user[email]" type="text" value="steve@example.com">
281
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="text" value="steve@example.com">
282
282
  </div>
283
283
  ```
284
284
 
@@ -294,7 +294,7 @@ This generates:
294
294
  ```html
295
295
  <div class="mb-3">
296
296
  <label class="form-label visually-hidden required" for="user_email">Email</label>
297
- <input class="form-control" id="user_email" name="user[email]" placeholder="Email" type="text" value="steve@example.com">
297
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" placeholder="Email" required="required" type="text" value="steve@example.com">
298
298
  </div>
299
299
  ```
300
300
 
@@ -312,7 +312,7 @@ This generates:
312
312
  ```html
313
313
  <div class="mb-3">
314
314
  <label class="form-label required" for="user_email">Email</label>
315
- <input class="custom-class" id="user_email" name="user[email]" type="text" value="steve@example.com">
315
+ <input aria-required="true" class="custom-class" id="user_email" name="user[email]" required="required" type="text" value="steve@example.com">
316
316
  </div>
317
317
  ```
318
318
 
@@ -438,7 +438,7 @@ This generates:
438
438
  <div class="mb-3">
439
439
  <label class="form-label required" for="user_email">Email</label>
440
440
  <div class="input-group input-group-lg">
441
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
441
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
442
442
  <input class="btn btn-primary" data-disable-with="Subscribe" name="commit" type="submit" value="Subscribe">
443
443
  </div>
444
444
  </div>
@@ -503,7 +503,7 @@ Generated HTML:
503
503
 
504
504
  ```html
505
505
  <div class="mb-3">
506
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
506
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
507
507
  </div>
508
508
  ```
509
509
 
@@ -771,7 +771,7 @@ This generates:
771
771
  ```html
772
772
  <div class="mb-3">
773
773
  <label class="form-label required" for="user_email">Email</label>
774
- <input class="form-control-plaintext" id="user_email" name="user[email]" readonly type="text" value="steve@example.com">
774
+ <input aria-required="true" class="form-control-plaintext" id="user_email" name="user[email]" readonly required="required" type="text" value="steve@example.com">
775
775
  </div>
776
776
  ```
777
777
 
@@ -791,7 +791,7 @@ This generates:
791
791
  <div class="mb-3 row">
792
792
  <label class="form-label col-form-label col-sm-2 required" for="user_email">Email</label>
793
793
  <div class="col-sm-10">
794
- <input class="form-control-plaintext" id="user_email" name="user[email]" readonly type="text" value="steve@example.com">
794
+ <input aria-required="true" class="form-control-plaintext" id="user_email" name="user[email]" readonly required="required" type="text" value="steve@example.com">
795
795
  </div>
796
796
  </div>
797
797
  </form>
@@ -1054,7 +1054,7 @@ This generates:
1054
1054
  <form accept-charset="UTF-8" action="/users" class="new_user row row-cols-auto g-3 align-items-center" id="new_user" method="post">
1055
1055
  <div class="col">
1056
1056
  <label class="form-label visually-hidden mr-sm-2 required" for="user_email">Email</label>
1057
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1057
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1058
1058
  </div>
1059
1059
  <div class="col">
1060
1060
  <label class="form-label visually-hidden mr-sm-2" for="user_password">Password</label>
@@ -1116,7 +1116,7 @@ This generates:
1116
1116
  <div class="mb-3 row">
1117
1117
  <label class="form-label col-form-label col-sm-2 required" for="user_email">Email</label>
1118
1118
  <div class="col-sm-10">
1119
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1119
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1120
1120
  </div>
1121
1121
  </div>
1122
1122
  <div class="mb-3 row">
@@ -1134,7 +1134,7 @@ This generates:
1134
1134
  </div>
1135
1135
  </div>
1136
1136
  </div>
1137
-
1137
+
1138
1138
  <div class="mb-3 row">
1139
1139
  <div class="col-sm-10 offset-sm-2">
1140
1140
  <input class="btn btn-secondary" data-disable-with="Create User" name="commit" type="submit" value="Create User">
@@ -1163,7 +1163,7 @@ This generates:
1163
1163
  <div class="mb-3 row">
1164
1164
  <label class="form-label col-form-label col-sm-2 required" for="user_email">Email</label>
1165
1165
  <div class="col-sm-10">
1166
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1166
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1167
1167
  </div>
1168
1168
  </div>
1169
1169
  <div class="mb-3 row">
@@ -1220,7 +1220,7 @@ This generates:
1220
1220
  <div class="mb-3 row">
1221
1221
  <label class="form-label col-form-label col-sm-2 required" for="user_email">Email</label>
1222
1222
  <div class="col-sm-10">
1223
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1223
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1224
1224
  </div>
1225
1225
  </div>
1226
1226
  <div class="mb-3 row">
@@ -1260,7 +1260,7 @@ This generates:
1260
1260
  <div class="mb-3 row">
1261
1261
  <label class="form-label col-form-label col-sm-2 required" for="user_email">Email</label>
1262
1262
  <div class="col-sm-10">
1263
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1263
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1264
1264
  </div>
1265
1265
  </div>
1266
1266
  <div class="mb-3">
@@ -1301,7 +1301,7 @@ This generates:
1301
1301
  <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
1302
1302
  <div class="mb-3">
1303
1303
  <label class="form-label required" for="user_email">Email</label>
1304
- <input class="form-control" id="user_email" name="user[email]" type="email" value="steve@example.com">
1304
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="steve@example.com">
1305
1305
  </div>
1306
1306
  <div class="mb-3">
1307
1307
  <label class="form-label" for="user_password">Password</label>
@@ -1337,7 +1337,7 @@ This generates:
1337
1337
  ```html
1338
1338
  <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
1339
1339
  <div class="mb-3 form-floating">
1340
- <input class="form-control" id="user_email" name="user[email]" placeholder="Email" type="email" value="steve@example.com">
1340
+ <input aria-required="true" class="form-control" id="user_email" name="user[email]" placeholder="Email" required="required" type="email" value="steve@example.com">
1341
1341
  <label class="form-label required" for="user_email">Email</label>
1342
1342
  </div>
1343
1343
  <div class="mb-3 form-floating">
@@ -1553,7 +1553,7 @@ This generates:
1553
1553
  ```html
1554
1554
  <div class="mb-3">
1555
1555
  <label class="form-label required" for="user_login">New Username</label>
1556
- <input class="form-control" id="user_login" name="user[login]" required="required" type="password">
1556
+ <input aria-required="true" class="form-control" id="user_login" name="user[login]" required="required" type="password">
1557
1557
  </div>
1558
1558
  <div class="mb-3">
1559
1559
  <label class="form-label" for="user_password">New Password</label>
@@ -1561,6 +1561,53 @@ This generates:
1561
1561
  </div>
1562
1562
  ```
1563
1563
 
1564
+ ### Required belongs_to associations
1565
+
1566
+ Adding a form control for a `belongs_to` field will automatically pick up the associated presence validator.
1567
+
1568
+ ![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51")
1569
+ ```erb
1570
+ <%= bootstrap_form_for(@address, url: '/address') do |f| %>
1571
+ <%= f.collection_select :user_id, @users, :id, :email, include_blank: "Select a value" %>
1572
+ <%= f.text_field :street %>
1573
+ <%= f.text_field :city %>
1574
+ <%= f.text_field :state %>
1575
+ <%= f.text_field :zip_code %>
1576
+ <%= f.submit "Save" %>
1577
+ <% end %>
1578
+ ```
1579
+
1580
+ Generated HTML:
1581
+
1582
+ ```html
1583
+ <form accept-charset="UTF-8" action="/address" class="new_address" id="new_address_1" method="post">
1584
+ <div class="mb-3">
1585
+ <label class="form-label required" for="address_user_id">User</label>
1586
+ <select class="form-select" id="address_user_id" name="address[user_id]">
1587
+ <option value="">Select a value</option>
1588
+ <option value="">steve@example.com</option>
1589
+ </select>
1590
+ </div>
1591
+ <div class="mb-3">
1592
+ <label class="form-label" for="address_street">Street</label>
1593
+ <input class="form-control" id="address_street" name="address[street]" type="text" value="Foo">
1594
+ </div>
1595
+ <div class="mb-3">
1596
+ <label class="form-label" for="address_city">City</label>
1597
+ <input class="form-control" id="address_city" name="address[city]" type="text">
1598
+ </div>
1599
+ <div class="mb-3">
1600
+ <label class="form-label" for="address_state">State</label>
1601
+ <input class="form-control" id="address_state" name="address[state]" type="text">
1602
+ </div>
1603
+ <div class="mb-3">
1604
+ <label class="form-label" for="address_zip_code">Zip code</label>
1605
+ <input class="form-control" id="address_zip_code" name="address[zip_code]" type="text">
1606
+ </div>
1607
+ <input class="btn btn-secondary" data-disable-with="Save" name="commit" type="submit" value="Save">
1608
+ </form>
1609
+ ```
1610
+
1564
1611
  ## Internationalization
1565
1612
 
1566
1613
  bootstrap_form follows standard rails conventions so it's i18n-ready. See more
data/RELEASING.md CHANGED
@@ -11,7 +11,18 @@ Follow these steps to release a new version of bootstrap_form to rubygems.org.
11
11
  ## How to release
12
12
 
13
13
  1. Run `BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update` to make sure that you have all the gems necessary for testing and releasing.
14
- 2. **Ensure the tests are passing by running `BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update`.** (Currently this step shows a lot of warnings about method redefinitions, but otherwise everything must be green before release.)
14
+ 2. **Ensure the tests are passing by running the tests**
15
+
16
+ (There should be no errors or warnings.)
17
+
18
+ BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle exec rake test
19
+
20
+ 2. **Ensure the demo tests are passing by running**
21
+
22
+ cd demo
23
+ bundle update
24
+ bundle exec rake test:all
25
+
15
26
  3. Determine which would be the correct next version number according to [semver](http://semver.org/).
16
27
  4. Update the version in `./lib/bootstrap_form/version.rb`.
17
28
  5. Update the GitHub diff links at the beginning of `CHANGELOG.md` (The pattern should be obvious when you look at them).