rails_bootstrap_form 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/rails_bootstrap_form.css +1 -0
  4. data/demo/.byebug_history +4 -0
  5. data/demo/.ruby-version +1 -0
  6. data/demo/Rakefile +10 -0
  7. data/demo/app/assets/config/manifest.js +1 -0
  8. data/demo/app/assets/stylesheets/application.scss +3 -0
  9. data/demo/app/channels/application_cable/channel.rb +8 -0
  10. data/demo/app/channels/application_cable/connection.rb +8 -0
  11. data/demo/app/controllers/application_controller.rb +6 -0
  12. data/demo/app/controllers/users_controller.rb +70 -0
  13. data/demo/app/helpers/application_helper.rb +6 -0
  14. data/demo/app/jobs/application_job.rb +6 -0
  15. data/demo/app/mailers/application_mailer.rb +8 -0
  16. data/demo/app/models/address.rb +10 -0
  17. data/demo/app/models/application_record.rb +7 -0
  18. data/demo/app/models/country.rb +17 -0
  19. data/demo/app/models/fruit.rb +14 -0
  20. data/demo/app/models/skill.rb +21 -0
  21. data/demo/app/models/user.rb +20 -0
  22. data/demo/app/models/user_skill.rb +8 -0
  23. data/demo/app/views/layouts/application.html.erb +15 -0
  24. data/demo/app/views/users/_form.html.erb +5 -0
  25. data/demo/app/views/users/_form_without_bootstrap_helpers.html.erb +49 -0
  26. data/demo/app/views/users/_vertical_form.html.erb +33 -0
  27. data/demo/app/views/users/edit.html.erb +1 -0
  28. data/demo/app/views/users/index.html.erb +42 -0
  29. data/demo/app/views/users/new.html.erb +1 -0
  30. data/demo/bin/bundle +111 -0
  31. data/demo/bin/rails +8 -0
  32. data/demo/bin/rake +8 -0
  33. data/demo/bin/setup +37 -0
  34. data/demo/config/application.rb +28 -0
  35. data/demo/config/boot.rb +9 -0
  36. data/demo/config/cable.yml +10 -0
  37. data/demo/config/database.yml +25 -0
  38. data/demo/config/environment.rb +9 -0
  39. data/demo/config/environments/development.rb +74 -0
  40. data/demo/config/environments/production.rb +97 -0
  41. data/demo/config/environments/test.rb +64 -0
  42. data/demo/config/initializers/assets.rb +16 -0
  43. data/demo/config/initializers/content_security_policy.rb +29 -0
  44. data/demo/config/initializers/filter_parameter_logging.rb +12 -0
  45. data/demo/config/initializers/inflections.rb +20 -0
  46. data/demo/config/initializers/permissions_policy.rb +17 -0
  47. data/demo/config/initializers/rails_bootstrap_form.rb +10 -0
  48. data/demo/config/locales/en.rb +16 -0
  49. data/demo/config/puma.rb +47 -0
  50. data/demo/config/routes.rb +9 -0
  51. data/demo/config/storage.yml +34 -0
  52. data/demo/config.ru +10 -0
  53. data/demo/db/migrate/20230514054308_create_countries.rb +12 -0
  54. data/demo/db/migrate/20230514054851_create_fruits.rb +12 -0
  55. data/demo/db/migrate/20230514055237_create_users.rb +21 -0
  56. data/demo/db/migrate/20230514055840_create_addresses.rb +17 -0
  57. data/demo/db/migrate/20230514060556_create_skills.rb +12 -0
  58. data/demo/db/migrate/20230514061100_create_user_skills.rb +13 -0
  59. data/demo/db/schema.rb +69 -0
  60. data/demo/db/seeds.rb +15 -0
  61. data/demo/public/favicon.ico +0 -0
  62. data/lib/generators/rails_bootstrap_form/install_generator.rb +25 -0
  63. data/lib/generators/rails_bootstrap_form/templates/install.rb +10 -0
  64. data/lib/rails_bootstrap_form/action_view_extensions/bootstrap_form_helper.rb +54 -0
  65. data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +24 -0
  66. data/lib/rails_bootstrap_form/bootstrap_form_options.rb +71 -0
  67. data/lib/rails_bootstrap_form/configuration.rb +26 -0
  68. data/lib/rails_bootstrap_form/version.rb +1 -1
  69. data/lib/rails_bootstrap_form.rb +20 -1
  70. metadata +66 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7bfd166fa3219fe70750aef616b04fd1c97868599069fa2ff183d8ddcf3e67e
4
- data.tar.gz: 31f62bf43a6416e8f6fb614af743fbac0a1f12d77a47c016311315677ab27375
3
+ metadata.gz: 7902b4c3c6edd102d01a2008a8d69a639b6afde3a93997c202e9267dcda93e4b
4
+ data.tar.gz: 4e65ba157ac848d45093d2aeda0673e840335bafd24b5861b0551dddc6cd130b
5
5
  SHA512:
6
- metadata.gz: 401b57c7fcf0c4ed07c85e4afc91c26e7869613637eff3b9e284f4863cfd334c4290cba1301df20a4f2f4e07542b66b78ec25ec93439629942974d41217ff6f4
7
- data.tar.gz: '0989527684b68dfb44aecfa6605ccef61a118afade847d6117461f89c68946fdb5fbe90f4ebfcec59b21e5263fefe01020c4ddeef0a345dedafffcaa6dbf4f1a'
6
+ metadata.gz: 1641aaa9fa84627e32bd9d5d59c7bfb6c89f12fd7498a6ed443309125ee11b4a79a8f7636b55da81e28a003146e00707c89df0d10c2e2d58957a975a035af3dc
7
+ data.tar.gz: 9ecea91f9b5c2af60282eb938e957e18cbfcbc7b089341b126db05728cdb44dd41cb4af9632e1cf6e6a14b6146a3b5c8841af3cd3c95a24b7c77af8dabcd6d10
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_bootstrap_form (0.1.0)
4
+ rails_bootstrap_form (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,4 @@
1
+ c
2
+ @bootstrap_form_options
3
+ c
4
+ @bootstrap_form_options
@@ -0,0 +1 @@
1
+ ruby-3.2.2
data/demo/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
6
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
7
+
8
+ require_relative "config/application"
9
+
10
+ Rails.application.load_tasks
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,3 @@
1
+ @charset "utf-8";
2
+ @import "bootstrap";
3
+ @import "rails_bootstrap_form"
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ module ApplicationCable
6
+ class Channel < ActionCable::Channel::Base
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ module ApplicationCable
6
+ class Connection < ActionCable::Connection::Base
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class ApplicationController < ActionController::Base
6
+ end
@@ -0,0 +1,70 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class UsersController < ApplicationController
6
+
7
+ before_action :find_user, except: [:index, :new, :create]
8
+
9
+ def index
10
+ @users = ::User.all
11
+ end
12
+
13
+ def new
14
+ @user = ::User.new
15
+ end
16
+
17
+ def create
18
+ @user = ::User.new(user_params)
19
+ if @user.save
20
+ redirect_to users_path
21
+ else
22
+ render :new, status: :unprocessable_entity
23
+ end
24
+ end
25
+
26
+ def edit
27
+ end
28
+
29
+ def update
30
+ if @user.update(user_params)
31
+ redirect_to users_path
32
+ else
33
+ render :edit, status: :unprocessable_entity
34
+ end
35
+ end
36
+
37
+ def destroy
38
+ @user.destroy
39
+ redirect_to users_path
40
+ end
41
+
42
+ private
43
+
44
+ def user_params
45
+ params.require(:user).permit(
46
+ :name,
47
+ :email,
48
+ :password,
49
+ :mobile_number,
50
+ :birth_date,
51
+ :terms,
52
+ :excellence,
53
+ :blog_url,
54
+ :fruit_id,
55
+ :favorite_color,
56
+ skill_ids: [],
57
+ address_attributes: [
58
+ :street,
59
+ :state,
60
+ :city,
61
+ :postal_code,
62
+ :country_id,
63
+ ]
64
+ )
65
+ end
66
+
67
+ def find_user
68
+ @user = ::User.find(params.fetch(:id))
69
+ end
70
+ end
@@ -0,0 +1,6 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ module ApplicationHelper
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class ApplicationJob < ActiveJob::Base
6
+ end
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class ApplicationMailer < ActionMailer::Base
6
+ default from: "from@example.com"
7
+ layout "mailer"
8
+ end
@@ -0,0 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class Address < ApplicationRecord
6
+ belongs_to :user
7
+ belongs_to :country
8
+
9
+ delegate :name, to: :country, prefix: true
10
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class ApplicationRecord < ActiveRecord::Base
6
+ primary_abstract_class
7
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class Country < ApplicationRecord
6
+ DEFAULT_OPTIONS = [
7
+ "India",
8
+ "Ireland",
9
+ "United States",
10
+ "United Kingdom",
11
+ "Spain",
12
+ "France",
13
+ "Canada"
14
+ ].freeze
15
+
16
+ has_many :addresses, dependent: :restrict_with_exception
17
+ end
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class Fruit < ApplicationRecord
6
+ DEFAULT_OPTIONS = [
7
+ "Mango",
8
+ "Apple",
9
+ "Orange",
10
+ "Watermelon"
11
+ ].freeze
12
+
13
+ has_many :users, dependent: :restrict_with_exception
14
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class Skill < ApplicationRecord
6
+ DEFAULT_OPTIONS = [
7
+ "Communication",
8
+ "Problem Solving",
9
+ "Leadership",
10
+ "Writing",
11
+ "Creativity",
12
+ "Time Management",
13
+ "Team Work",
14
+ "Negotiation",
15
+ "Decision Making",
16
+ "Management"
17
+ ].freeze
18
+
19
+ has_many :user_skills, dependent: :restrict_with_exception
20
+ has_many :users, through: :user_skills, source: :user
21
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class User < ApplicationRecord
6
+ has_one :address, dependent: :destroy
7
+
8
+ has_many :user_skills, dependent: :destroy
9
+ has_many :skills, through: :user_skills, source: :skill
10
+
11
+ belongs_to :fruit
12
+
13
+ delegate :name, to: :fruit, prefix: true
14
+
15
+ accepts_nested_attributes_for :address, update_only: true
16
+
17
+ def address
18
+ super.presence || build_address
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ class UserSkill < ApplicationRecord
6
+ belongs_to :user
7
+ belongs_to :skill
8
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsBootstrapForms - Demo Application</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+ <%= stylesheet_link_tag "application" %>
9
+ </head>
10
+ <body>
11
+ <div class="container-fluid p-3">
12
+ <%= yield %>
13
+ </div>
14
+ </body>
15
+ </html>
@@ -0,0 +1,5 @@
1
+ <% if false %>
2
+ <%= render partial: "users/form_without_bootstrap_helpers" %>
3
+ <% end %>
4
+
5
+ <%= render partial: "users/vertical_form" %>
@@ -0,0 +1,49 @@
1
+ <div class="card card-primary my-3">
2
+ <div class="card-header fw-bold">
3
+ Profile Form (Without RailsBootstrapForm)
4
+ </div>
5
+ <div class="card-body">
6
+ <%= form_for @user do |form| %>
7
+ <%= form.text_field :name, autocomplete: "new-name" %>
8
+ <%= form.email_field :email %>
9
+ <%= form.password_field :password, autocomplete: "new-password" %>
10
+ <%= form.phone_field :mobile_number %>
11
+ <%= form.date_field :birth_date %>
12
+ <%= form.check_box :terms %>
13
+ <%= form.range_field :excellence %>
14
+ <%= form.url_field :blog_url %>
15
+ <%= form.url_field :favorite_color %>
16
+ <%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id), include_blank: "Select Favorite Fruit" %>
17
+ <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name do |b| %>
18
+ <%= b.check_box + b.text %>
19
+ <% end %>
20
+ <%= form.fields_for :address, include_id: false do |address_form| %>
21
+ <%= address_form.text_area :street %>
22
+ <%= address_form.text_field :state %>
23
+ <%= address_form.text_field :city %>
24
+ <%= address_form.text_field :postal_code %>
25
+ <%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id), include_blank: "Select Country" %>
26
+ <% end %>
27
+ <div class="mt-3">
28
+ <%= form.submit "Register", class: "btn btn-primary" %>
29
+ <%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
30
+ </div>
31
+ <% end %>
32
+ </div>
33
+ </div>
34
+
35
+ <div class="card card-primary">
36
+ <div class="card-header fw-bold">
37
+ Login Form (Without RailsBootstrapForm)
38
+ </div>
39
+ <div class="card-body">
40
+ <%= form_for @user do |form| %>
41
+ <%= form.email_field :email %>
42
+ <%= form.password_field :password, autocomplete: "new-password" %>
43
+ <div class="mt-3">
44
+ <%= form.submit "Login", class: "btn btn-primary" %>
45
+ <%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
46
+ </div>
47
+ <% end %>
48
+ </div>
49
+ </div>
@@ -0,0 +1,33 @@
1
+ <div class="card card-primary my-3">
2
+ <div class="card-header fw-bold">
3
+ Profile Form (Vertical layout)
4
+ </div>
5
+ <div class="card-body">
6
+ <%= bootstrap_form_for @user, bootstrap_form: {} do |form| %>
7
+ <%= form.text_field :name, autocomplete: "new-name", required: true, bootstrap_form: {} %>
8
+ <%= form.text_field :email, autocomplete: "new-email", bootstrap_form: {} %>
9
+ <%= form.text_field :password, autocomplete: "new-password" %>
10
+ <%= form.phone_field :mobile_number %>
11
+ <%= form.date_field :birth_date %>
12
+ <%= form.check_box :terms %>
13
+ <%= form.range_field :excellence %>
14
+ <%= form.url_field :blog_url %>
15
+ <%= form.url_field :favorite_color %>
16
+ <%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id), include_blank: "Select Favorite Fruit" %>
17
+ <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name do |b| %>
18
+ <%= b.check_box + b.text %>
19
+ <% end %>
20
+ <%= form.fields_for :address, include_id: false do |address_form| %>
21
+ <%= address_form.text_area :street %>
22
+ <%= address_form.text_field :state %>
23
+ <%= address_form.text_field :city %>
24
+ <%= address_form.text_field :postal_code %>
25
+ <%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id), {include_blank: "Select Country", bootstrap: {}} %>
26
+ <% end %>
27
+ <div class="mt-3">
28
+ <%= form.submit "Register", class: "btn btn-primary" %>
29
+ <%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
30
+ </div>
31
+ <% end %>
32
+ </div>
33
+ </div>
@@ -0,0 +1 @@
1
+ <%= render partial: "form" %>
@@ -0,0 +1,42 @@
1
+ <div class="card card-primary">
2
+ <div class="card-header">
3
+ <div class="text-end">
4
+ <%= link_to "New user", new_user_path, class: "btn btn-primary" %>
5
+ </div>
6
+ </div>
7
+ <div class="card-body">
8
+ <div class="table-responsive mt-3">
9
+ <table class="table table-bordered table-stripped">
10
+ <thead>
11
+ <tr>
12
+ <th scope="col">#</th>
13
+ <th scope="col">Name</th>
14
+ <th scope="col">Email</th>
15
+ <th scope="col">Mobile number</th>
16
+ <th scope="col">Favorite Fruit</th>
17
+ <th scope="col">Country</th>
18
+ <th scope="col" width="15%">Actions</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @users.each.with_index(1) do |user, index| %>
23
+ <tr style="vertical-align: middle;">
24
+ <td><%= index %></td>
25
+ <td><%= user.name %></td>
26
+ <td><%= user.email %></td>
27
+ <td><%= user.mobile_number %></td>
28
+ <td><%= user.fruit_name %></td>
29
+ <td><%= user.address.country_name %></td>
30
+ <td>
31
+ <%= link_to "Edit", edit_user_path(user), class: "btn btn-sm btn-secondary" %>
32
+ <div class="d-inline-block">
33
+ <%= button_to "Delete", user, class: "btn btn-sm btn-danger", method: :delete %>
34
+ </div>
35
+ </td>
36
+ </tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+ </div>
42
+ </div>
@@ -0,0 +1 @@
1
+ <%= render partial: "form" %>
data/demo/bin/bundle ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # -*- frozen_string_literal: true -*-
4
+ # -*- warn_indent: true -*-
5
+
6
+ #
7
+ # This file was generated by Bundler.
8
+ #
9
+ # The application 'bundle' is installed as part of a gem, and
10
+ # this file is here to facilitate running it.
11
+ #
12
+
13
+ require "rubygems"
14
+
15
+ m = Module.new do
16
+ module_function
17
+
18
+ def invoked_as_script?
19
+ File.expand_path($0) == File.expand_path(__FILE__)
20
+ end
21
+
22
+ def env_var_version
23
+ ENV["BUNDLER_VERSION"]
24
+ end
25
+
26
+ def cli_arg_version
27
+ return unless invoked_as_script? # don't want to hijack other binstubs
28
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
29
+ bundler_version = nil
30
+ update_index = nil
31
+ ARGV.each_with_index do |a, i|
32
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
33
+ bundler_version = a
34
+ end
35
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
36
+ bundler_version = $1
37
+ update_index = i
38
+ end
39
+ bundler_version
40
+ end
41
+
42
+ def gemfile
43
+ gemfile = ENV["BUNDLE_GEMFILE"]
44
+ return gemfile if gemfile && !gemfile.empty?
45
+
46
+ File.expand_path("../Gemfile", __dir__)
47
+ end
48
+
49
+ def lockfile
50
+ lockfile =
51
+ case File.basename(gemfile)
52
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
53
+ else "#{gemfile}.lock"
54
+ end
55
+ File.expand_path(lockfile)
56
+ end
57
+
58
+ def lockfile_version
59
+ return unless File.file?(lockfile)
60
+ lockfile_contents = File.read(lockfile)
61
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
62
+ Regexp.last_match(1)
63
+ end
64
+
65
+ def bundler_requirement
66
+ @bundler_requirement ||=
67
+ env_var_version ||
68
+ cli_arg_version ||
69
+ bundler_requirement_for(lockfile_version)
70
+ end
71
+
72
+ def bundler_requirement_for(version)
73
+ return "#{Gem::Requirement.default}.a" unless version
74
+
75
+ bundler_gem_version = Gem::Version.new(version)
76
+
77
+ bundler_gem_version.approximate_recommendation
78
+ end
79
+
80
+ def load_bundler!
81
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
82
+
83
+ activate_bundler
84
+ end
85
+
86
+ def activate_bundler
87
+ gem_error = activation_error_handling do
88
+ gem "bundler", bundler_requirement
89
+ end
90
+ return if gem_error.nil?
91
+ require_error = activation_error_handling do
92
+ require "bundler/version"
93
+ end
94
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
95
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
96
+ exit 42
97
+ end
98
+
99
+ def activation_error_handling
100
+ yield
101
+ nil
102
+ rescue StandardError, LoadError => e
103
+ e
104
+ end
105
+ end
106
+
107
+ m.load_bundler!
108
+
109
+ if m.invoked_as_script?
110
+ load Gem.bin_path("bundler", "bundle")
111
+ end
data/demo/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # -*- frozen_string_literal: true -*-
4
+ # -*- warn_indent: true -*-
5
+
6
+ APP_PATH = File.expand_path("../config/application", __dir__)
7
+ require_relative "../config/boot"
8
+ require "rails/commands"
data/demo/bin/rake ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # -*- frozen_string_literal: true -*-
4
+ # -*- warn_indent: true -*-
5
+
6
+ require_relative "../config/boot"
7
+ require "rake"
8
+ Rake.application.run
data/demo/bin/setup ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # -*- frozen_string_literal: true -*-
4
+ # -*- warn_indent: true -*-
5
+
6
+ require "fileutils"
7
+
8
+ # path to your application root.
9
+ APP_ROOT = File.expand_path("..", __dir__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ FileUtils.chdir APP_ROOT do
16
+ # This script is a way to set up or update your development environment automatically.
17
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
18
+ # Add necessary setup steps to this file.
19
+
20
+ puts "== Installing dependencies =="
21
+ system! "gem install bundler --conservative"
22
+ system("bundle check") || system!("bundle install")
23
+
24
+ # puts "\n== Copying sample files =="
25
+ # unless File.exist?("config/database.yml")
26
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
27
+ # end
28
+
29
+ puts "\n== Preparing database =="
30
+ system! "bin/rails db:prepare"
31
+
32
+ puts "\n== Removing old logs and tempfiles =="
33
+ system! "bin/rails log:clear tmp:clear"
34
+
35
+ puts "\n== Restarting application server =="
36
+ system! "bin/rails restart"
37
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ require_relative "boot"
6
+
7
+ require "rails/all"
8
+
9
+ # Require the gems listed in Gemfile, including any gems
10
+ # you've limited to :test, :development, or :production.
11
+ Bundler.require(*Rails.groups)
12
+
13
+ module Demo
14
+ class Application < Rails::Application
15
+ # Initialize configuration defaults for originally generated Rails version.
16
+ config.load_defaults 7.0
17
+
18
+ # Configuration for the application, engines, and railties goes here.
19
+ #
20
+ # These settings can be overridden in specific environments using the files
21
+ # in config/environments, which are processed later.
22
+ #
23
+ # config.time_zone = "Central Time (US & Canada)"
24
+ # config.eager_load_paths << Rails.root.join("extras")
25
+
26
+ config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**", "*.{rb,yml,yaml}")]
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # -*- frozen_string_literal: true -*-
3
+ # -*- warn_indent: true -*-
4
+
5
+ # Set up gems listed in the Gemfile.
6
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __dir__)
7
+
8
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
9
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: demo_production