bootstrap_form 2.7.0 → 4.0.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +14 -0
  3. data/.travis.yml +29 -0
  4. data/CHANGELOG.md +227 -0
  5. data/CONTRIBUTING.md +57 -0
  6. data/Dangerfile +54 -0
  7. data/Gemfile +21 -0
  8. data/{MIT-LICENSE → LICENSE.txt} +1 -1
  9. data/README.md +154 -87
  10. data/Rakefile +5 -15
  11. data/UPGRADE-4.0.md +79 -0
  12. data/bootstrap_form.gemspec +28 -0
  13. data/demo/README.md +17 -0
  14. data/demo/Rakefile +6 -0
  15. data/demo/app/controllers/application_controller.rb +2 -0
  16. data/demo/app/controllers/bootstrap_controller.rb +16 -0
  17. data/demo/app/helpers/bootstrap_helper.rb +23 -0
  18. data/{test/dummy → demo}/app/models/address.rb +0 -0
  19. data/demo/app/models/application_record.rb +3 -0
  20. data/{test/dummy → demo}/app/models/faux_user.rb +0 -0
  21. data/{test/dummy → demo}/app/models/super_user.rb +0 -0
  22. data/{test/dummy → demo}/app/models/user.rb +0 -0
  23. data/demo/app/views/bootstrap/form.html.erb +53 -0
  24. data/demo/app/views/layouts/application.html.erb +65 -0
  25. data/demo/bin/bundle +3 -0
  26. data/{test/dummy → demo}/bin/rails +1 -1
  27. data/{test/dummy → demo}/bin/rake +0 -0
  28. data/demo/bin/setup +36 -0
  29. data/demo/bin/update +31 -0
  30. data/demo/bin/yarn +11 -0
  31. data/{test/dummy → demo}/config.ru +2 -1
  32. data/demo/config/application.rb +24 -0
  33. data/demo/config/boot.rb +5 -0
  34. data/{test/dummy → demo}/config/database.yml +8 -12
  35. data/demo/config/environment.rb +5 -0
  36. data/demo/config/environments/development.rb +60 -0
  37. data/{test/dummy → demo}/config/environments/test.rb +15 -20
  38. data/demo/config/initializers/application_controller_renderer.rb +8 -0
  39. data/demo/config/initializers/assets.rb +14 -0
  40. data/{test/dummy → demo}/config/initializers/backtrace_silencers.rb +0 -0
  41. data/demo/config/initializers/cookies_serializer.rb +5 -0
  42. data/{test/dummy → demo}/config/initializers/filter_parameter_logging.rb +0 -0
  43. data/{test/dummy → demo}/config/initializers/inflections.rb +0 -0
  44. data/{test/dummy → demo}/config/initializers/mime_types.rb +0 -1
  45. data/{test/dummy → demo}/config/initializers/wrap_parameters.rb +2 -2
  46. data/{test/dummy → demo}/config/locales/en.yml +10 -0
  47. data/demo/config/puma.rb +56 -0
  48. data/{test/dummy → demo}/config/routes.rb +2 -0
  49. data/demo/config/spring.rb +6 -0
  50. data/demo/config/storage.yml +35 -0
  51. data/demo/db/schema.rb +24 -0
  52. data/{test/dummy/public/favicon.ico → demo/log/.keep} +0 -0
  53. data/demo/package.json +5 -0
  54. data/demo/public/favicon.ico +0 -0
  55. data/lib/bootstrap_form/form_builder.rb +221 -96
  56. data/lib/bootstrap_form/helper.rb +26 -16
  57. data/lib/bootstrap_form/helpers/bootstrap.rb +37 -24
  58. data/lib/bootstrap_form/version.rb +1 -1
  59. metadata +67 -252
  60. data/lib/bootstrap_form/helpers/nested_form.rb +0 -33
  61. data/test/bootstrap_checkbox_test.rb +0 -144
  62. data/test/bootstrap_fields_test.rb +0 -152
  63. data/test/bootstrap_form_group_test.rb +0 -289
  64. data/test/bootstrap_form_test.rb +0 -209
  65. data/test/bootstrap_other_components_test.rb +0 -86
  66. data/test/bootstrap_radio_button_test.rb +0 -124
  67. data/test/bootstrap_selects_test.rb +0 -160
  68. data/test/dummy/Gemfile +0 -45
  69. data/test/dummy/Gemfile.lock +0 -120
  70. data/test/dummy/README.rdoc +0 -28
  71. data/test/dummy/Rakefile +0 -10
  72. data/test/dummy/app/assets/javascripts/application.js +0 -16
  73. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  74. data/test/dummy/app/controllers/application_controller.rb +0 -5
  75. data/test/dummy/app/helpers/application_helper.rb +0 -2
  76. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  77. data/test/dummy/bin/bundle +0 -3
  78. data/test/dummy/config/application.rb +0 -23
  79. data/test/dummy/config/boot.rb +0 -4
  80. data/test/dummy/config/environment.rb +0 -5
  81. data/test/dummy/config/environments/development.rb +0 -29
  82. data/test/dummy/config/environments/production.rb +0 -80
  83. data/test/dummy/config/initializers/secret_token.rb +0 -12
  84. data/test/dummy/config/initializers/session_store.rb +0 -3
  85. data/test/dummy/db/migrate/20130703191909_create_users.rb +0 -13
  86. data/test/dummy/db/migrate/20130703191937_create_addresses.rb +0 -13
  87. data/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb +0 -5
  88. data/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb +0 -5
  89. data/test/dummy/db/migrate/20140922133133_add_type_to_users.rb +0 -5
  90. data/test/dummy/db/schema.rb +0 -39
  91. data/test/dummy/db/seeds.rb +0 -7
  92. data/test/dummy/db/test.sqlite3 +0 -0
  93. data/test/dummy/log/test.log +0 -38160
  94. data/test/dummy/public/404.html +0 -58
  95. data/test/dummy/public/422.html +0 -58
  96. data/test/dummy/public/500.html +0 -57
  97. data/test/dummy/public/robots.txt +0 -5
  98. data/test/dummy/test/fixtures/addresses.yml +0 -15
  99. data/test/dummy/test/fixtures/users.yml +0 -15
  100. data/test/dummy/test/models/address_test.rb +0 -7
  101. data/test/dummy/test/models/user_test.rb +0 -7
  102. data/test/dummy/test/test_helper.rb +0 -15
  103. data/test/special_form_class_models_test.rb +0 -43
  104. data/test/test_helper.rb +0 -86
data/Rakefile CHANGED
@@ -1,37 +1,27 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
17
11
  rdoc.title = 'BootstrapForm'
18
12
  rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('README.md')
20
14
  rdoc.rdoc_files.include('lib/**/*.rb')
21
15
  end
22
16
 
23
-
24
-
25
- Bundler::GemHelper.install_tasks
17
+ require 'bundler/gem_tasks'
26
18
 
27
19
  require 'rake/testtask'
28
20
 
29
21
  Rake::TestTask.new(:test) do |t|
30
- t.libs << 'lib'
31
22
  t.libs << 'test'
32
23
  t.pattern = 'test/**/*_test.rb'
33
24
  t.verbose = false
34
25
  end
35
26
 
36
-
37
- task :default => :test
27
+ task default: :test
@@ -0,0 +1,79 @@
1
+ # Upgrading to `bootstrap_form` 4.0
2
+ We made every effort to make the upgrade from `bootstrap_form` v2.7 (Bootstrap 3) to `bootstrap_form` v4.0 (Bootstrap 4) as easy as possible. However, Bootstrap 4 is fundamentally different from Bootstrap 3, so some changes may be necessary in your code.
3
+
4
+ ## Bootstrap 4 Changes
5
+ If you made use of Bootstrap classes or Javascript, you should read the [Bootstrap 4 migration guide](https://getbootstrap.com/docs/4.0/migration/).
6
+
7
+ ## Validation Error Messages
8
+ With Bootstrap 4, in order for validation error messages to display, the message has to be a sibling of the `input` tag, and the `input` tag has to have the `.is-invalid` class. This was different from Bootstrap 3, and forced some changes to `bootstrap_form` that may affect programs that used `bootstrap_form` v2.7.
9
+
10
+ ### Arbitrary Text in `form_group` Blocks
11
+ In `bootstrap_form` v2.7, it was possible to write something like this:
12
+ ```
13
+ <%= bootstrap_form_for(@user) do |f| %>
14
+ <%= f.form_group(:email) do %>
15
+ <p class="form-control-static">Bar</p>
16
+ <%= end %>
17
+ <%= end %>
18
+ ```
19
+ and, if `@user.email` had validation errors, it would render:
20
+ ```
21
+ <div class="form-group has-error">
22
+ <p class="form-control-static">Bar</p>
23
+ <span class="help-block">can't be blank, is too short (minimum is 5 characters)</span>
24
+ </div>
25
+ ```
26
+ which would show an error message in red.
27
+
28
+ That doesn't work in Bootstrap 4. Outputting error messages had to be moved to accommodate other changes, so `form_group` no longer outputs error messages unless whatever is inside the block is a `bootstrap_form` helper.
29
+
30
+ One way to make the above behave the same in `bootstrap_form` v4.0 is to write it like this:
31
+
32
+ ```
33
+ <%= bootstrap_form_for(@user) do |f| %>
34
+ <%= f.form_group(:email) do %>
35
+ <p class="form-control-plaintext">Bar</p>
36
+ <%= content_tag(:div, @user.errors[:email].join(", "), class: "invalid-feedback", style: "display: block;") unless @user.errors[:email].empty? %>
37
+ <%= end %>
38
+ <%= end %>
39
+ ```
40
+
41
+ ### Check Boxes and Radio Buttons
42
+ Bootstrap 4 marks up check boxes and radio buttons differently. In particular, Bootstrap 4 wraps the `input` and `label` tags in a `div.form-check` tag. Because validation error messages have to be siblings of the `input` tag, there is now an `error_message` option to `check_box` and `radio_button` to cause them to put the validation error messages inside the `div.form-check`.
43
+
44
+ This change is mostly invisible to existing programs:
45
+
46
+ - Since the default for `error_message` is false, use of `check_box` and `radio_button` all by themselves behaves the same as in `bootstrap_form` v2.7
47
+ - All the `collection*` helpers that output radio buttons and check boxes arrange to produce the validation error message on the last check box or radio button of the group, like `bootstrap_form` v2.7 did
48
+
49
+ There is one situation where an existing program will have to change. When rendering one or more check boxes or radio buttons inside a `form_group` block, the last call to `check_box` or `radio_button` in the block will have to have `error_message: true` added to its parameters, like this:
50
+
51
+ ```
52
+ <%= bootstrap_form_for(@user) do |f| %>
53
+ <%= f.form_group(:education) do %>
54
+ <%= f.radio_button(:misc, "primary school") %>
55
+ <%= f.radio_button(:misc, "high school") %>
56
+ <%= f.radio_button(:misc, "university", error_message: true) %>
57
+ <%= end %>
58
+ <%= end %>
59
+ ```
60
+
61
+ ## `form-group` and Horizontal Forms
62
+ In Bootstrap 3, `.form-group` mixed in `.row`. In Bootstrap 4, it doesn't. So `bootstrap_form` automatically adds `.row` to the `div.form-group`s that it creates, if the form group is in a horizontal layout. When migrating forms from the Bootstrap 3 version of `bootstrap_form` to the Bootstrap 4 version, check all horizontal forms to be sure they're being rendered properly.
63
+
64
+ Bootstrap 4 also provides a `.form-row`, which has smaller gutters than `.row`. If you specify ".form-row", `bootstrap_form` will replace `.row` with `.form-row` on the `div.form-group`. When calling `form_group` directly, do something like this:
65
+ ```
66
+ bootstrap_form_for(@user, layout: "horizontal") do |f|
67
+ f.form_group class: "form-row" do
68
+ ...
69
+ end
70
+ end
71
+ ```
72
+ For the other helpers, do something like this:
73
+ ```
74
+ bootstrap_form_for(@user, layout: "horizontal") do |f|
75
+ f.form_group class: "form-row" do
76
+ f.text_field wrapper_class: "form-row" # or f.text_field wrapper: { class: "form-row" }
77
+ ...
78
+ end
79
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require "bootstrap_form/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "bootstrap_form"
8
+ s.version = BootstrapForm::VERSION
9
+ s.authors = ["Stephen Potenza", "Carlos Lopes"]
10
+ s.email = ["potenza@gmail.com", "carlos.el.lopes@gmail.com"]
11
+ s.homepage = "https://github.com/bootstrap-ruby/bootstrap_form"
12
+ s.summary = "Rails form builder that makes it easy to style forms using "\
13
+ "Bootstrap 4"
14
+ s.description = "bootstrap_form is a rails form builder that makes it super "\
15
+ "easy to create beautiful-looking forms using Bootstrap 4"
16
+ s.license = "MIT"
17
+
18
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test)/})
20
+ end
21
+
22
+ s.bindir = "exe"
23
+ s.require_paths = ["lib"]
24
+
25
+ s.required_ruby_version = ">= 2.2.2"
26
+
27
+ s.add_dependency "rails", ">= 5.0"
28
+ end
@@ -0,0 +1,17 @@
1
+ # DEMO APP (Rails 5.2)
2
+
3
+ ### Usage
4
+
5
+ - `rake db:schema:load`
6
+ - `rails s`
7
+ - Navigate to http://localhost:3000
8
+
9
+ ### Following files were added or changed:
10
+
11
+ - db/schema.rb
12
+ - config/{application, routes, boot}.rb
13
+ - config/environments/{development, test}.rb
14
+ - app/models/{address,user,super_user,faux_user}.rb
15
+ - app/controllers/bootstrap_controller.rb
16
+ - app/views/layouts/application.html.erb
17
+ - app/views/bootstrap/form.html.erb
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,16 @@
1
+ class BootstrapController < ApplicationController
2
+
3
+ def form
4
+ @collection = [
5
+ Address.new(id: 1, street: 'Foo'),
6
+ Address.new(id: 2, street: 'Bar')
7
+ ]
8
+
9
+ @user = User.new
10
+
11
+ @user_with_error = User.new
12
+ @user_with_error.errors.add(:email)
13
+ @user_with_error.errors.add(:misc)
14
+ end
15
+
16
+ end
@@ -0,0 +1,23 @@
1
+ module BootstrapHelper
2
+
3
+ def form_with_source(&block)
4
+ form_html = capture(&block)
5
+
6
+ content_tag(:div, class: "example") do
7
+ codemirror = content_tag(:div, class: "code", style: "display: none") do
8
+ content_tag(:textarea, class: "codemirror") do
9
+ HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<"))
10
+ end
11
+ end
12
+
13
+ toggle = content_tag(:button, class: "toggle btn btn-sm btn-info") do
14
+ "Show Source Code"
15
+ end
16
+
17
+ concat(form_html)
18
+ concat(toggle)
19
+ concat(codemirror)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
File without changes
@@ -0,0 +1,53 @@
1
+ <h3>Horizontal Form</h3>
2
+
3
+ <%= form_with_source do %>
4
+ <%= bootstrap_form_for @user, layout: :horizontal do |form| %>
5
+ <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
6
+ <%= form.password_field :password, placeholder: "Password" %>
7
+ <%= form.select :status, [['activated', 1], ['blocked', 2]], prompt: "Please Select" %>
8
+ <%= form.text_area :misc %>
9
+ <%= form.check_box :terms, label: "Agree to Terms" %>
10
+ <%= form.collection_check_boxes :misc, @collection, :id, :street %>
11
+ <%= form.collection_radio_buttons :misc, @collection, :id, :street %>
12
+ <%= form.file_field :misc %>
13
+ <%= form.datetime_select :misc, include_blank: true %>
14
+
15
+ <%= form.submit %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <h3>With Validation Error</h3>
20
+
21
+ <%= form_with_source do %>
22
+ <%= bootstrap_form_for @user_with_error, layout: :horizontal do |form| %>
23
+ <%= form.alert_message "This is an alert" %>
24
+ <%= form.error_summary %>
25
+ <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
26
+ <%= form.collection_check_boxes :misc, @collection, :id, :street %>
27
+ <%= form.submit %>
28
+ <% end %>
29
+ <% end %>
30
+
31
+ <h3>Inline Form</h3>
32
+
33
+ <%= form_with_source do %>
34
+ <%= bootstrap_form_for @user, layout: :inline do |form| %>
35
+ <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
36
+ <%= form.password_field :password, placeholder: "Password" %>
37
+ <%= form.check_box :terms, label: "Agree to Terms" %>
38
+ <%= form.collection_check_boxes :misc, @collection, :id, :street %>
39
+ <%= form.submit %>
40
+ <% end %>
41
+ <% end %>
42
+
43
+ <h3>Simple</h3>
44
+
45
+ <%= form_with_source do %>
46
+ <%= bootstrap_form_for @user, url: "/" do |form| %>
47
+ <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
48
+ <%= form.password_field :password, placeholder: "Password" %>
49
+ <%= form.check_box :terms, label: "Agree to Terms" %>
50
+ <%= form.collection_check_boxes :misc, @collection, :id, :street %>
51
+ <%= form.submit %>
52
+ <% end %>
53
+ <% end %>
@@ -0,0 +1,65 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <!-- Required meta tags -->
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+
8
+ <!-- Bootstrap CSS -->
9
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
10
+
11
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.33.0/codemirror.min.css">
12
+
13
+ <style type="text/css">
14
+ .example {
15
+ padding: 1.5em;
16
+ border: .2rem solid #f7f7f9;
17
+ margin-bottom: 3em;
18
+ }
19
+ form {
20
+ margin-bottom: 1.5em;
21
+ }
22
+ .CodeMirror {
23
+ border: 1px solid #eee;
24
+ height: auto;
25
+ }
26
+ .rails-bootstrap-forms-datetime-select select {
27
+ display: inline-block;
28
+ width: auto;
29
+ }
30
+ </style>
31
+
32
+ <title>Hello, world!</title>
33
+ <%= csrf_meta_tags %>
34
+ </head>
35
+
36
+ <body>
37
+ <div class="container">
38
+ <%= yield %>
39
+ </div>
40
+
41
+ <!-- Optional JavaScript -->
42
+ <!-- jQuery first, then Popper.js, then Bootstrap JS -->
43
+ <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
44
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
45
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
46
+
47
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.33.0/codemirror.min.js"></script>
48
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.33.0/mode/htmlmixed/htmlmixed.min.js"></script>
49
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.33.0/mode/xml/xml.min.js"></script>
50
+
51
+ <script type="text/javascript">
52
+ $(document).on("click", "button.toggle", function(){
53
+ var example = $(this).parent(".example");
54
+ $(this).hide();
55
+ $(".code", example).show()
56
+ CodeMirror.fromTextArea($("textarea.codemirror", example)[0], {
57
+ mode: "htmlmixed",
58
+ tabSize: 2,
59
+ lineNumbers: true,
60
+ viewportMargin: Infinity
61
+ })
62
+ });
63
+ </script>
64
+ </body>
65
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
3
  require_relative '../config/boot'
4
4
  require 'rails/commands'
File without changes
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a starting point to setup your application.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(' ')}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end