bullet_train 1.0.45 → 1.1.0

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.bt-link +0 -0
  3. data/README.md +4 -3
  4. data/app/controllers/concerns/account/controllers/base.rb +9 -0
  5. data/app/controllers/concerns/account/invitations/controller_base.rb +11 -6
  6. data/app/controllers/concerns/account/teams/controller_base.rb +1 -1
  7. data/app/controllers/concerns/controllers/base.rb +26 -2
  8. data/app/controllers/concerns/registrations/controller_base.rb +4 -7
  9. data/app/controllers/concerns/root_redirect.rb +1 -5
  10. data/app/controllers/concerns/sessions/controller_base.rb +0 -6
  11. data/app/controllers/sessions_controller.rb +11 -0
  12. data/app/controllers/turbo_devise_controller.rb +19 -0
  13. data/app/helpers/account/dates_helper.rb +10 -8
  14. data/app/helpers/account/forms_helper.rb +0 -4
  15. data/app/helpers/account/locale_helper.rb +2 -2
  16. data/app/helpers/base_helper.rb +5 -1
  17. data/app/helpers/concerns/helpers/base.rb +18 -0
  18. data/app/helpers/invitations_helper.rb +0 -15
  19. data/app/javascript/controllers/bulk_action_form_controller.js +88 -0
  20. data/app/javascript/controllers/bulk_actions_controller.js +95 -0
  21. data/app/javascript/controllers/clipboard_controller.js +1 -1
  22. data/app/javascript/controllers/form_controller.js +1 -1
  23. data/app/javascript/controllers/index.js +7 -1
  24. data/app/javascript/controllers/mobile_menu_controller.js +19 -17
  25. data/app/javascript/controllers/text_toggle_controller.js +33 -0
  26. data/app/mailers/concerns/mailers/base.rb +1 -0
  27. data/app/models/concerns/current_attributes/base.rb +1 -1
  28. data/app/models/concerns/memberships/base.rb +10 -2
  29. data/app/models/concerns/records/base.rb +35 -0
  30. data/app/models/concerns/teams/base.rb +19 -0
  31. data/app/models/concerns/users/base.rb +12 -11
  32. data/app/models/invitation.rb +1 -1
  33. data/app/models/membership.rb +1 -1
  34. data/app/models/team.rb +2 -2
  35. data/app/models/user.rb +1 -1
  36. data/app/views/account/memberships/show.html.erb +3 -1
  37. data/app/views/account/onboarding/user_details/edit.html.erb +1 -1
  38. data/app/views/account/users/_oauth.html.erb +2 -0
  39. data/app/views/account/users/edit.html.erb +2 -3
  40. data/app/views/bullet_train/partial_resolver.html.erb +1 -0
  41. data/app/views/devise/registrations/new.html.erb +1 -1
  42. data/app/views/devise/sessions/new.html.erb +6 -6
  43. data/app/views/layouts/docs.html.erb +25 -24
  44. data/app/views/layouts/mailer.html.erb +1 -425
  45. data/config/initializers/concerns/inflections_base.rb +6 -0
  46. data/config/initializers/concerns/turbo_failure_app.rb +14 -0
  47. data/config/locales/en/billing/products.en.yml +17 -0
  48. data/config/locales/en/devise.en.yml +1 -0
  49. data/config/locales/en/framework_packages.yml +43 -0
  50. data/config/locales/en/invitations.en.yml +1 -0
  51. data/config/locales/en/teams.en.yml +1 -0
  52. data/docs/action-models.md +148 -0
  53. data/docs/authentication.md +2 -2
  54. data/docs/billing/stripe.md +95 -39
  55. data/docs/field-partials/super-select.md +70 -1
  56. data/docs/field-partials.md +25 -18
  57. data/docs/getting-started.md +12 -12
  58. data/docs/index.md +4 -1
  59. data/docs/indirection.md +30 -7
  60. data/docs/invitation_only.md +13 -0
  61. data/docs/javascript.md +18 -0
  62. data/docs/namespacing.md +1 -1
  63. data/docs/onboarding.md +10 -10
  64. data/docs/overriding.md +1 -1
  65. data/docs/permissions.md +1 -1
  66. data/docs/super-scaffolding/delegated-types.md +31 -3
  67. data/docs/super-scaffolding/sortable.md +137 -0
  68. data/docs/super-scaffolding.md +7 -1
  69. data/docs/tunneling.md +4 -4
  70. data/lib/bullet_train/core_ext/string_emoji_helper.rb +18 -0
  71. data/lib/bullet_train/resolver.rb +61 -47
  72. data/lib/bullet_train/version.rb +1 -1
  73. data/lib/bullet_train.rb +23 -9
  74. data/lib/tasks/bullet_train_tasks.rake +148 -7
  75. metadata +115 -33
  76. data/app/assets/javascripts/bullet-train.esm.js +0 -2
  77. data/app/assets/javascripts/bullet-train.esm.js.map +0 -1
  78. data/app/assets/javascripts/bullet-train.js +0 -2
  79. data/app/assets/javascripts/bullet-train.js.map +0 -1
  80. data/app/assets/javascripts/bullet-train.modern.js +0 -2
  81. data/app/assets/javascripts/bullet-train.modern.js.map +0 -1
  82. data/app/assets/javascripts/bullet-train.umd.js +0 -2
  83. data/app/assets/javascripts/bullet-train.umd.js.map +0 -1
  84. data/lib/string/emoji.rb +0 -10
@@ -1,90 +1,146 @@
1
- # Enabling Stripe Subscriptions
1
+ # Bullet Train Billing for Stripe
2
2
 
3
- Bullet Train provides a base billing package and a Stripe-specific package with support for Stripe Checkout, Stripe Billing's customer portal, and incoming Stripe webhooks.
3
+ When you're ready to start billing customers for the product you've created with Bullet Train, you can take advantage of our streamlined, commercial billing package that includes a traditional SaaS pricing page powered by Yaml configuration for products and prices.
4
4
 
5
- ## 1. Add the `bullet_train-billing-stripe` Ruby gem.
5
+ We also provide a Stripe-specific adapter package with support for auto-configuring those products and prices in your Stripe account. It also takes advantage of completely modern Stripe workflows, like allowing customers to purchase your product with Stripe Checkout and later manage their subscription using Stripe Billing's customer portal. It also automatically handles incoming Stripe webhooks as well, to keep subscription state in your application up-to-date with activity that has happened on Stripe's platform.
6
6
 
7
- > TODO Add instructions about subscribing to Bullet Train Pro.
7
+ ## 1. Purchase Bullet Train Billing for Stripe
8
8
 
9
- ## 2. Migrate the Database
9
+ First, [purchase Bullet Train Billing for Stripe](https://buy.stripe.com/28o8zg4dBbrd59u7sM). Once you've completed this process, you'll be issued a private token for the Bullet Train Pro package server. (This process is currently completed manually, so please be patient.)
10
+
11
+ ## 2. Install the Package
12
+
13
+ ### 2.1. Add the Private Ruby Gems
14
+
15
+ You'll need to specify both Ruby gems in your `Gemfile`, since we have to specify a private source for both:
16
+
17
+ ```
18
+ source "https://YOUR_TOKEN_HERE@gem.fury.io/bullettrain" do
19
+ gem "bullet_train-billing"
20
+ gem "bullet_train-billing-stripe"
21
+ end
22
+ ```
23
+
24
+ ### 2.2. Bundle Install
25
+
26
+ ```
27
+ bundle install
28
+ ```
29
+
30
+ ### 2.3. Copy Database Migrations
31
+
32
+ Use the following two commands on your shell to copy the required migrations into your local project:
33
+
34
+ ```
35
+ cp `bundle show --paths | grep bullet_train-billing | sort | head -n 1`/db/migrate/* db/migrate
36
+ cp `bundle show --paths | grep bullet_train-billing-stripe | sort | head -n 1`/db/migrate/* db/migrate
37
+ ```
38
+
39
+ Note this is different than how many Rails engines ask you to install migrations. This is intentional, as we want to maintain the original timestamps associated with these migrations.
40
+
41
+ ### 2.4. Run Migrations
10
42
 
11
43
  ```
12
44
  rake db:migrate
13
45
  ```
14
46
 
15
- ## 3. Create API Keys with Stripe
47
+ ## 3. Configure Your Products
48
+
49
+ Bullet Train defines subscription plans and pricing options in `config/models/billing/products.yml` and defines the translatable elements of these plans in `config/locales/en/billing/products.en.yml`. We recommend just getting started with these plans to ensure your setup is working before customizing the attributes of these plans.
50
+
51
+ ## 4. Configure Stripe
52
+
53
+ ### 4.1. Create API Keys with Stripe
16
54
 
17
55
  - Create a Stripe account if you don't already have one.
18
- - Visit https://dashboard.stripe.com/apikeys.
19
- - For your development environment, make sure you toggle the "test mode" flag to "on" in the top-right corner.
56
+ - Visit [https://dashboard.stripe.com/test/apikeys](https://dashboard.stripe.com/test/apikeys).
20
57
  - Create a new secret key.
21
58
 
22
- ## 4. Configure Stripe API Keys Locally
59
+ **Note:** By default we're linking to the "test mode" page for API keys so you can get up and running in development. When you're ready to deploy to production, you'll have to repeat this step and toggle the "test mode" option off to provision real API keys for live payments.
60
+
61
+ ### 4.2. Configure Stripe API Keys Locally
23
62
 
24
- Edit `config/application.yml` and add your Stripe publishable key and new secret key to the file, and also tell the system to use Stripe subscriptions by default:
63
+ Edit `config/application.yml` and add your new Stripe secret key to the file:
25
64
 
26
65
  ```
27
- BILLING_DEFAULT_SUBSCRIPTION: "Billing::Stripe::Subscription"
28
- STRIPE_PUBLISHABLE_KEY: pk_0CJwz5wHlKBXxDA4VO1uEoipxQob0
29
66
  STRIPE_SECRET_KEY: sk_0CJw2Iu5wwIKXUDdqphrt2zFZyOCH
30
67
  ```
31
68
 
32
- ## 5. Populate Stripe with Locally Configured Products
69
+ ### 4.3. Populate Stripe with Locally Configured Products
33
70
 
34
- Bullet Train defines subscription plans and other purchasable add-ons in `config/models/billing/products.yml` and comes preconfigured with some example plans. We recommend just getting started with these plans to ensure your setup is working before customizing the attributes of these plans.
35
-
36
- Before you can use Stripe Checkout or Stripe Billing's customer portal, these products will have to be defined on Stripe as well. You can have all locally defined products automatically created on Stripe by running the following:
71
+ Before you can use Stripe Checkout or Stripe Billing's customer portal, your locally configured products will have to be created on Stripe as well. To accomplish this, you can have all locally defined products automatically created on Stripe via API by running the following:
37
72
 
38
73
  ```
39
74
  rake billing:stripe:populate_products_in_stripe
40
75
  ```
41
76
 
42
- ## 6. Import Additional Environment Variables
77
+ ### 4.4. Add Additional Environment Variables
43
78
 
44
79
  The script in the previous step will output some additional environment variables you need to copy into `config/application.yml`.
45
80
 
46
- ## 7. Restart Rails
47
81
 
48
- We've modified a bunch of environment variables, so you'll have to have to restart your Rails server before you see the results in your browser.
82
+ ## 5. Wire Up Webhooks
49
83
 
50
- ```
51
- rails restart
52
- ```
84
+ Basic subscription creation will work without receiving and processing Stripe's webhooks. However, advanced payment workflows like SCA payments and customer portal cancelations and plan changes require receiving webhooks and processing them.
53
85
 
54
- ## 8. Test Creating a Subscription
86
+ ### 5.1. Ensure HTTP Tunneling is Enabled
55
87
 
56
- Bullet Train comes preconfigured with a "freemium" plan, so new and existing accounts will continue to work as normal. A new "billing" menu item will appear and you can test subscription creation by clicking "upgrade" and selecting one of the two plans presented.
88
+ Although Stripe provides free tooling for receiving webhooks in your local environment, the officially supported mechanism for doing so in Bullet Train is using [HTTP Tunneling with ngrok](/docs/tunneling.md). This is because we provide support for many types of webhooks across different platforms and packages, so we already need to have ngrok in play.
57
89
 
58
- You should be in "test mode" on Stripe, so when prompted for a credit card number, you can enter `4242 4242 4242 4242`.
90
+ Ensure you've completed the steps from [HTTP Tunneling with ngrok](/docs/tunneling.md), including updating `BASE_URL` in `config/application.yml` and restarting your Rails server.
59
91
 
60
- ## 9. Configuring Webhooks
92
+ ### 5.2. Enable Stripe Webhooks
61
93
 
62
- Basic subscription creation will work without receiving and processing Stripe's webhooks. However, advanced payment workflows like SCA payments and customer portal cancelations and plan changes require receiving webhooks and processing them.
94
+ - Visit [https://dashboard.stripe.com/test/webhooks/create](https://dashboard.stripe.com/test/webhooks/create).
95
+ - Use the default "add an endpoint" form.
96
+ - Set "endpoint URL" to `https://YOUR-SUBDOMAIN.ngrok.io/webhooks/incoming/stripe_webhooks`.
97
+ - Under "select events to listen to" choose "select all events" and click "add events".
98
+ - Finalize the creation of the endpoint by clicking "add endpoint".
99
+
100
+ ### 5.3. Configure Stripe Webhooks Signing Secret
101
+
102
+ After creating the webhook endpoint, click "reveal" under the heading "signing secret". Copy the `whsec_...` value into your `config/application.yml` like so:
63
103
 
64
- - Stripe can't deliver webhooks to `http://localhost:3000`, so you'll need to [get an HTTP tunnel up and running](/docs/tunneling.md). For this example, we'll assume you're using ngrok.
65
- - Visit https://dashboard.stripe.com/test/webhooks/create.
66
- - Configure the "endpoint URL" to be `https://your-tunnel.ngrok.io/webhooks/incoming/stripe_webhooks`, replacing `your-tunnel` with whatever the subdomain of your tunnel is.
67
- - When configuring which events to receive, just "select all events" for simplicity. This ensures that any webhooks Bullet Train might add support for in the future will be properly handled when you upgrade.
68
- - Add the endpoint.
69
- - On the page for the webhook endpoint you've just configured with Stripe, click on "reveal" under the heading "signing secret". This is a secret token that is required to authenticate that webhooks your application is receiving are actually coming from Stripe. Copy this into your `config/application.yml` like so:
104
+ ```
105
+ STRIPE_WEBHOOKS_ENDPOINT_SECRET: whsec_vchvkw3hrLK7SmUiEenExipUcsCgahf9
106
+ ```
70
107
 
71
- ```
72
- STRIPE_WEBHOOKS_ENDPOINT_SECRET: whsec_VsM3c2zeZyqAddkaPaXzf1wJsYp2fRKR
73
- ```
108
+ ### 5.4. Test Sample Webhook Delivery
74
109
 
75
110
  - Restart your Rails server with `rails restart`.
76
111
  - Trigger a test webhook just to ensure it's resulting in an HTTP status code of 201.
77
112
 
78
- ## 10. Configure Stripe Billing's Customer Portal
113
+ ## 6. Test Creating a Subscription
79
114
 
80
- - Visit https://dashboard.stripe.com/test/settings/billing/portal.
115
+ Bullet Train comes preconfigured with a "freemium" plan, so new and existing accounts will continue to work as normal. A new "billing" menu item will appear and you can test subscription creation by clicking "upgrade" and selecting one of the two plans presented.
116
+
117
+ You should be in "test mode" on Stripe, so when prompted for a credit card number, you can enter `4242 4242 4242 4242`.
118
+
119
+ ## 7. Configure Stripe Billing's Customer Portal
120
+
121
+ - Visit [https://dashboard.stripe.com/test/settings/billing/portal](https://dashboard.stripe.com/test/settings/billing/portal).
81
122
  - Complete all required fields.
82
123
  - Be sure to add all of your actively available plans under "products".
83
124
 
84
125
  This "products" list is what Stripe will display to users as upgrade and downgrade options in the customer portal. You shouldn't list any products here that aren't properly configured in your Rails app, otherwise the resulting webhook will fail to process. If you want to stop offering a plan, you should remove it from this list as well.
85
126
 
86
- ## 11. Test Webhooks by Managing a Subscription
127
+ ## 8. Finalize Webhooks Testing by Managing a Subscription
87
128
 
88
129
  In the same account where you created your first test subscription, go into the "billing" menu and click "manage" on that subscription. This will take you to the Stripe Billing customer portal.
89
130
 
90
131
  Once you're in the customer portal, you should test upgrading, downgrading, and canceling your subscription and clicking "⬅ Return to {Your Application Name}" in between each step to ensure that each change you're making is properly reflected in your Bullet Train application. This will let you know that webhooks are being properly delivered and processed and all the products in both systems are properly mapped in both directions.
132
+
133
+ ## 9. Rinse and Repeat Configuration Steps for Production
134
+
135
+ As mentioned earlier, all of the links we provided for configuration steps on Stripe were linked to the "test mode" on your Stripe account. When you're ready to launch payments in production, you will need to:
136
+
137
+ - Complete all configuration steps again in the live version of your Stripe account. You can do this by following all the links in the steps above and toggling the "test mode" switch to visit the live mode version of each page.
138
+ - After creating a live API key, configure `STRIPE_SECRET_KEY` in your production environment.
139
+ - Run `STRIPE_SECRET_KEY=... rake billing:stripe:populate_products_in_stripe` (where `...` is your live secret key) in order to create live versions of your products and prices.
140
+ - Copy the environment variables output by that rake task into your production environment.
141
+ - Configure a live version of your webhooks endpoint for the production environment by following the same steps as before, but replacing the ngrok host with your production host in the endpoint URL.
142
+ - After creating the live webhooks endpoint, configure the corresponding signing secret as the `STRIPE_WEBHOOKS_ENDPOINT_SECRET` enviornment variable in your production environment.
143
+
144
+ ## 10. You should be done!
145
+
146
+ [Let us know on Discord](http://discord.gg/bullettrain) if any part of this guide was not clear or could be improved!
@@ -1,6 +1,6 @@
1
1
  # Examples for the `super_select` Field Partial
2
2
 
3
- The `super_select` partial provides a wonderful default UI (in contrast to the vanilla browser experience for this, which is horrible) with optional search and multi-select functionality out-of-the-box. It invokes the [Select2](https://select2.org) library to provide you these features.
3
+ The `super_select` partial provides a wonderful default UI (in contrast to the vanilla browser experience for this, which is horrible) with optional search and multi-select functionality out-of-the-box. It invokes the [Select2][select2] library to provide you these features.
4
4
 
5
5
  ## Define Available Buttons via Localization Yaml
6
6
 
@@ -56,3 +56,72 @@ Here is the same example, with search enabled:
56
56
  choices: @project.valid_memberships.map { |membership| [membership.name, membership.id] },
57
57
  html_options: {multiple: true}, other_options: {search: true} %>
58
58
  </code></pre>
59
+
60
+ ## Accepting New Entries
61
+
62
+ Here is an example allowing a new option to be entered by the user:
63
+
64
+ <pre><code><%= render 'shared/fields/super_select', form: form, method: :delay_minutes,
65
+ choices: %w(1 5 10 30).map { |value| [value, value] },
66
+ other_options: {accepts_new: true} %>
67
+ </code></pre>
68
+
69
+ Note: this will set the option `value` (which will be submitted to the server) to the entered text.
70
+ ## Events
71
+
72
+ All events dispatched from the `super_select` partial are [Select2's jQuery events][select2_events] re-dispatched as native DOM events with the following caveats:
73
+
74
+ 1. The native DOM event name is pre-pended with `$`
75
+ 2. The original jQuery event is passed through under `event.detail.event`
76
+
77
+ | Select2 event name | DOM event name |
78
+ |---------------------|----------------------|
79
+ | change | $change |
80
+ | select2:closing | $select2:closing |
81
+ | select2:close | $select2:close |
82
+ | select2:opening | $select2:opening |
83
+ | select2:open | $select2:open |
84
+ | select2:selecting | $select2:selecting |
85
+ | select2:select | $select2:select |
86
+ | select2:unselecting | $select2:unselecting |
87
+ | select2:unselect | $select2:unselect |
88
+ | select2:clearing | $select2:clearing |
89
+ | select2:clear | $select2:clear |
90
+
91
+ For example, catching the `$change` events in a parent `dependent-form-fields` Stimulus controller with a single `updateDependentFields` method would look like this:
92
+
93
+ <pre><code>&lt;div data-controller="dependent-form-fields"&gt;
94
+ &lt;div data-action="$change->dependent-form-fields#updateDependentFields"&gt;
95
+ <%= render 'shared/fields/super_select', form: form, method: :category_id,
96
+ choices: Category.all.map { |category| [category.label_string, category.id] } %>
97
+ &lt;/div&gt;
98
+ &lt;div&gt;
99
+ &lt;!-- This is the dependent field that would get updated when the previous one changes --&gt;
100
+ <%= render 'shared/fields/super_select', form: form, method: :category_id,
101
+ choices: Category.all.map { |category| [category.label_string, category.id] },
102
+ html_options: { data: { 'dependent-form-fields-target': 'dependentField' }} %>
103
+ &lt;/div&gt;
104
+ &lt;/div&gt;</code></pre>
105
+
106
+ And this is an example of what the `dependent-form-fields` Stimulus controller would look like.
107
+
108
+ <pre><code>
109
+ // dependent_form_fields_controller.js
110
+ import { Controller } from "stimulus"
111
+
112
+ export default class extends Controller {
113
+ static targets = [ "dependentField" ]
114
+
115
+ updateDependentFields(event) {
116
+ const originalSelect2Event = event.detail.event
117
+ console.log(`catching event ${event.type}`, originalSelect2Event)
118
+
119
+ this.dependentFieldTargets.forEach((dependentField) => {
120
+ // update dependentField based on value found in originalSelect2Event.target.value
121
+ })
122
+ }
123
+ }
124
+ </code></pre>
125
+
126
+ [select2]: https://select2.org
127
+ [select2_events]: https://select2.org/programmatic-control/events
@@ -76,7 +76,7 @@ When you're including multiple fields, you can DRY up redundant settings (e.g. `
76
76
  ```
77
77
 
78
78
  ## Field partials that integrate with third-party service providers
79
- - `cloudinary` makes it trivial to upload photos and images to [Cloudinary](https://cloudinary.com) and store their resulting Cloudinary ID as an attribute of the model backing the form.
79
+ - `cloudinary` makes it trivial to upload photos and images to [Cloudinary](https://cloudinary.com) and store their resulting Cloudinary ID as an attribute of the model backing the form. To enable this field partial, sign up for Cloudinary and copy the "Cloudinary URL" they provide you with into your `config/application.yml` as `CLOUDINARY_URL`. If you use our [Heroku app.json] to provision your production environment, this will happen in that environment automatically.
80
80
 
81
81
  ## Yaml Configuration
82
82
  The localization Yaml file (where you configure label and option values for a field) is automatically generated when you run Super Scaffolding for a model. If you haven't done this yet, the localization Yaml file for `Scaffolding::CompletelyConcrete::TangibleThing` serves as a good example. Under `en.scaffolding/completely_concrete/tangible_things.fields` you'll see definitions like this:
@@ -109,23 +109,30 @@ Certain form field partials like `buttons` and `super_select` can also have thei
109
109
 
110
110
  ## Available Field Partials
111
111
 
112
- | Field Partial | Multiple Values? | Assignment Helpers | JavaScript Library | Description | Commercial License Required |
113
- | --- | --- | --- | --- | --- | --- |
114
- | `boolean` | | `assign_boolean` | | | |
115
- | [`buttons`](/docs/field-partials/buttons.md) | Optionally | `assign_checkboxes` | | | |
116
- | `cloudinary_image` | | | | | |
117
- | `color_picker` | | | [pickr](https://simonwep.github.io/pickr/) | | |
118
- | `date_and_time_field` | | `assign_date_and_time` | [Date Range Picker](https://www.daterangepicker.com) | | |
119
- | `date_field` | | `assign_date` | [Date Range Picker](https://www.daterangepicker.com) | | |
120
- | `email_field` | | | | | |
121
- | `file_field` | | | [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) | | |
122
- | `options` | Optionally | `assign_checkboxes` | | | |
123
- | `password_field` | | | | | |
124
- | `phone_field` | | | [International Telephone Input](https://intl-tel-input.com) | Ensures telephone numbers are in a format that can be used by providers like Twilio. | |
125
- | [`super_select`](/docs/field-partials/super-select.md) | Optionally | `assign_select_options` | [Select2](https://select2.org) | Provides powerful option search, AJAX search, and multi-select functionality. | |
126
- | `text_area` | | | | | |
127
- | `text_field` | | | | | |
128
- | `trix_editor` | | | [Trix](https://github.com/basecamp/trix) | Basic HTML-powered formatting features and support for at-mentions amongst team members. | |
112
+ | Field Partial | Data Type | Multiple Values? | Assignment Helpers | JavaScript Library | Description | Commercial License Required |
113
+ | --- | --- | --- | --- | --- | --- | --- |
114
+ | `boolean` | `boolean` | `assign_boolean` | | | |
115
+ | [`buttons`](/docs/field-partials/buttons.md) | `string` | Optionally | `assign_checkboxes` | | | |
116
+ | `cloudinary_image` | `string` | | | | | |
117
+ | `color_picker` | | | | [pickr](https://simonwep.github.io/pickr/) | | |
118
+ | `date_and_time_field` | `datetime` | | `assign_date_and_time` | [Date Range Picker](https://www.daterangepicker.com) | | |
119
+ | `date_field` | `date` | | `assign_date` | [Date Range Picker](https://www.daterangepicker.com) | | |
120
+ | `email_field` | `string` | | | | | |
121
+ | `file_field` | `attachment` | | [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) | | |
122
+ | `options` | `string` | Optionally | `assign_checkboxes` | | | |
123
+ | `password_field` | `string` | | | | | |
124
+ | `phone_field` | `string` | | | [International Telephone Input](https://intl-tel-input.com) | Ensures telephone numbers are in a format that can be used by providers like Twilio. | |
125
+ | [`super_select`](/docs/field-partials/super-select.md) | `string` | Optionally | `assign_select_options` | [Select2](https://select2.org) | Provides powerful option search, AJAX search, and multi-select functionality. | |
126
+ | `text_area` | `text` | | | | | |
127
+ | `text_field` | `string` | | | | | |
128
+ | `trix_editor` | `text` | | | [Trix](https://github.com/basecamp/trix) | Basic HTML-powered formatting features and support for at-mentions amongst team members. | |
129
+
130
+ ## A Note On Data Types
131
+ Set the data type to `jsonb` whenever passing the `multiple` option to a new attribute.
132
+ ```
133
+ > rails generate model Project team:references multiple_buttons:jsonb
134
+ > bin/super-scaffold crud Project Team multiple_buttons:buttons{multiple}
135
+ ```
129
136
 
130
137
  ## Additional Field Partials Documentation
131
138
  - [`buttons`](/docs/field-partials/buttons.md)
@@ -11,45 +11,45 @@ If you're using Bullet Train for the first time, begin by learning these five im
11
11
  1. Use `rails g model` to create and `bin/super-scaffold` to scaffold a new model:
12
12
 
13
13
  ```
14
- $ rails g model Project team:references name:string
15
- $ bin/super-scaffold crud Project Team name:text_field
14
+ rails g model Project team:references name:string
15
+ bin/super-scaffold crud Project Team name:text_field
16
16
  ```
17
17
 
18
- In this example, `Team` refers to the immediate parent of the `Project` resource. For more details, just run `bin/super-scaffold` or [read the documentation](https://github.com/bullet-train-co/bullet_train-base/blob/main/docs/super-scaffolding.md).
18
+ In this example, `Team` refers to the immediate parent of the `Project` resource. For more details, just run `bin/super-scaffold` or [read the documentation](/docs/super-scaffolding.md).
19
19
 
20
20
  2. Use `rails g migration` and `bin/super-scaffold` to add a new field to a model you've already scaffolded:
21
21
 
22
22
  ```
23
- $ rails g migration add_description_to_projects description:text
24
- $ bin/super-scaffold crud-field Project description:trix_editor
23
+ rails g migration add_description_to_projects description:text
24
+ bin/super-scaffold crud-field Project description:trix_editor
25
25
  ```
26
26
 
27
- These first two points about Super Scaffolding are just the tip of the iceberg, so be sure to circle around and [read the full documentation](https://github.com/bullet-train-co/bullet_train-base/blob/main/docs/super-scaffolding.md).
27
+ These first two points about Super Scaffolding are just the tip of the iceberg, so be sure to circle around and [read the full documentation](/docs/super-scaffolding.md).
28
28
 
29
29
  3. Figure out which ERB views are powering something you see in the UI by:
30
30
 
31
31
  - Right clicking the element.
32
32
  - Selecting "Inspect Element".
33
- - Looking for the `<!--XRAY START ...-->` comment above the element you've selected.
33
+ - Looking for the `<!-- BEGIN ... -->` comment above the element you've selected.
34
34
 
35
35
  4. Figure out the full I18N translation key of any string on the page by adding `?show_locales=true` to the URL.
36
36
 
37
37
  5. Use `bin/resolve` to figure out where framework or theme things are coming from and eject them if you need to customize something locally:
38
38
 
39
39
  ```
40
- $ bin/resolve Users::Base
41
- $ bin/resolve en.account.teams.show.header --open
42
- $ bin/resolve shared/box --open --eject
40
+ bin/resolve Users::Base
41
+ bin/resolve en.account.teams.show.header --open
42
+ bin/resolve shared/box --open --eject
43
43
  ```
44
44
 
45
45
  Also, for inputs that can't be provided on the shell, there's an interactive mode where you can paste them:
46
46
 
47
47
  ```
48
- $ bin/resolve --interactive --eject --open
48
+ bin/resolve --interactive --eject --open
49
49
  ```
50
50
 
51
51
  And then paste any input, e.g.:
52
52
 
53
53
  ```
54
- <!--XRAY START 73 /Users/andrewculver/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/commentary/_box.html.erb-->
54
+ <!-- BEGIN /Users/andrewculver/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/commentary/_box.html.erb -->
55
55
  ```
data/docs/index.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bullet Train Developer Documentation
2
2
 
3
- > This release of Bullet Train is still a pre-release, so please pardon the dust while we work to complete the documentation for certain topics.
3
+ > Some of the open-source Bullet Train packages are considered pre-release, so please pardon the dust while we work to complete the documentation for certain topics.
4
4
 
5
5
  ## Introduction
6
6
  - [What is Bullet Train?](https://bullettrain.co) <i class="ti ti-new-window ml-2"></i>
@@ -12,9 +12,11 @@
12
12
  - [Dealing with Indirection](/docs/indirection.md)
13
13
  - [Overriding the Framework](/docs/overriding.md)
14
14
  - [Setting up a Tunnel](/docs/tunneling.md)
15
+ - [JavaScript](/docs/javascript.md)
15
16
 
16
17
  ## Developer Tools
17
18
  - [Super Scaffolding](/docs/super-scaffolding.md)
19
+ - [Action Models](/docs/action-models.md)
18
20
  - [Database Seeds](/docs/seeds.md)
19
21
  - [Test Suite](/docs/testing.md)
20
22
  - [Point-and-Click Test Writing](https://github.com/bullet-train-co/magic_test) <i class="ti ti-new-window ml-2"></i>
@@ -25,6 +27,7 @@
25
27
  - [Roles and Permissions](/docs/permissions.md)
26
28
  - [Onboarding](/docs/onboarding.md)
27
29
  - [Namespacing](/docs/namespacing.md)
30
+ - [Invitation Only Mode](/docs/invitation_only.md)
28
31
 
29
32
  ## UI
30
33
  - [Field Partials](/docs/field-partials.md)
data/docs/indirection.md CHANGED
@@ -27,20 +27,43 @@ Even in vanilla Rails development, when you're looking at a view file, the path
27
27
  `bin/resolve` makes it easy to figure out where where a partial is being served from:
28
28
 
29
29
  ```
30
- $ bin/resolve shared/box
30
+ bin/resolve shared/box
31
31
  ```
32
32
 
33
- ### Exposing Rendered Views with Xray
33
+ ### Exposing Rendered Views with Annotated Views
34
34
 
35
- > TODO Is this still true in Rails 7? Does it not do something like this by default now?
35
+ If you're looking at a rendered view in the browser, it can be hard to know which file to open in order to make a change. To help, Bullet Train enables `config.action_view.annotate_rendered_view_with_filenames` by default, so you can right click on any element you see, select "Inspect Element", and you'll see comments in the HTML source telling you which file is powering a particular portion of the view, like this:
36
36
 
37
- If you're looking at a rendered view in the browser, it can be hard to know which file to open in order to make a change. To help, Bullet Train includes [Xray](https://github.com/brentd/xray-rails) by default, so you can right click on any element you see, select "Inspect Element", and you'll see comments in the HTML source telling you which file is powering a particular portion of the view, like this:
37
+ ```
38
+ <!-- BEGIN /Users/andrewculver/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/workflow/_box.html.erb -->
39
+ ```
40
+
41
+ If you want to customize files like this that you find annotated in your browser, you can use the `--interactive` flag to eject the file to your main application, or simply open it in your code editor.
38
42
 
39
43
  ```
40
- <!--XRAY START 90 /Users/andrewculver/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/workflow/_box.html.erb-->
44
+ > bin/resolve --interactive
45
+
46
+ OK, paste what you've got for us and hit <Return>!
47
+
48
+ <!-- BEGIN /Users/andrewculver/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/workflow/_box.html.erb -->
49
+
50
+ Absolute path:
51
+ /Users/andrewculver/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/workflow/_box.html.erb
52
+
53
+ Package name:
54
+ bullet_train-themes-light-1.0.10
55
+
56
+
57
+ Would you like to eject the file into the local project? (y/n)
58
+ n
59
+
60
+ Would you like to open `/Users/andrewculver/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bullet_train-themes-light-1.0.10/app/views/themes/light/workflow/_box.html.erb`? (y/n)
61
+ y
41
62
  ```
42
63
 
43
- Note that in the example above, the view in question isn't actually coming from the application repository. Instead, it's being included from the `bullet_train-themes-light` package. For instructions on how to customize it, see [Overriding the Framework](/docs/override).
64
+ You may also want to consider using `bin/develop`, which will clone the Bullet Train package of your choice to `local/` within your main application's root directory. Running this command will also automatically link the package to your main application and open it in the code editor for you, so you can start using the cloned repository and make changes to your main application right away.
65
+
66
+ Note that in the example above, the view in question isn't actually coming from the application repository. Instead, it's being included from the `bullet_train-themes-light` package. For further instructions on how to customize it, see [Overriding Framework Defaults](/docs/overriding.md).
44
67
 
45
68
  ### Drilling Down on Translation Keys
46
69
 
@@ -59,5 +82,5 @@ You can also log all the translation key for anything being rendered to the cons
59
82
  Once you have the full I18N translation key, you can use `bin/resolve` to figure out which package and file it's coming from. At that point, if you need to customize it, you can also use the `--eject` option to copy the the framework for customization in your local application:
60
83
 
61
84
  ```
62
- $ bin/resolve en.account.onboarding.user_details.edit.header --eject --open
85
+ bin/resolve en.account.onboarding.user_details.edit.header --eject --open
63
86
  ```
@@ -0,0 +1,13 @@
1
+ # Invitation Only Mode
2
+
3
+ By providing a randomized string to `ENV["INVITATION_KEYS"]`, you can enable invitation only mode on your Bullet Train application. This will set up your app so that users cannot register to your website unless they have access to a specific link, or if they are invited via email.
4
+
5
+ `config/application.yml`:
6
+ ```ruby
7
+ INVITATION_KEYS: ofr9h5h9ghzeodh
8
+ ```
9
+
10
+ In this case, the user will be able to register their own account by accessing the following link:
11
+ ```
12
+ http://localhost:3000/invitations?key=ofr9h5h9ghzeodh
13
+ ```
@@ -0,0 +1,18 @@
1
+ # JavaScript
2
+ Bullet Train leans into the use of [Stimulus](https://stimulus.hotwired.dev) for custom JavaScript. If you haven't read it previously, [the original introductory blog post for Stimulus from 2018](https://medium.com/signal-v-noise/stimulus-1-0-a-modest-javascript-framework-for-the-html-you-already-have-f04307009130) was groundbreaking in its time, and we still consider it required reading for understanding the philosophy of JavaScript in Bullet Train.
3
+
4
+ ## Writing Custom JavaScript
5
+ The happy path for writing new custom JavaScript is to [write it as a Stimulus controller](https://stimulus.hotwired.dev/handbook/building-something-real) in `app/javascript/controllers` and invoke it by augmenting the HTML in your views. If you name the file `*_controller.js`, it will be automatically picked up and compiled as part of your application's JavaScript bundle.
6
+
7
+ ## npm Packages
8
+ npm packages are managed by [Yarn](https://yarnpkg.com) and any required importing can be done in `app/javascript/application.js`.
9
+
10
+ ## Compilation
11
+ Bullet Train uses [esbuild](https://esbuild.github.io) to compile all local JavaScript and npm package dependencies. If you haven't used esbuild before, it's blazing fast compared to older options like Webpack. Honestly, it makes JavaScript development and deployment in complex applications a joy again, in a way it hasn't been for years.
12
+
13
+ In development, the esbuild process that compiles JavaScript is defined as `yarn build` in `package.json`. This script also has an entry in `Procfile.dev`, so it runs automatically when you start your application with `bin/dev`, and when run in this context, it watches the filesystem and automatically recompiles anytime JavaScript files change on disk.
14
+
15
+ The resulting JavaScript bundle is output to the `app/assets/builds` directory where it is picked up by the traditional Rails asset pipeline. This directory is listed in `.gitignore`, so the compiled bundles are never committed to the repository.
16
+
17
+ ## React, Vue.js, etc.
18
+ We're not against the use of front-end JavaScript frameworks in the specific contexts where they're the best tool for the job, but we solidly subscribe to the "heavy machinery" philosophy put forward in [that original Stimulus blog post](https://medium.com/signal-v-noise/stimulus-1-0-a-modest-javascript-framework-for-the-html-you-already-have-f04307009130), and have no interest in actually supporting them.
data/docs/namespacing.md CHANGED
@@ -7,5 +7,5 @@ Bullet Train comes preconfigured with an `Account` and controller and view names
7
7
  In Bullet Train applications with [multiple team types](/docs/teams.md), you may find it helpful to introduce additional controller and view namespaces to represent and organize user interfaces and experiences for certain team types that vary substantially from the `Account` namespace default. In Super Scaffolding, you can specify a namespace other than `Account` with the `--namespace` option, for example:
8
8
 
9
9
  ```
10
- $ bin/super-scaffold crud Event Team name:text_field --namespace=customers
10
+ bin/super-scaffold crud Event Team name:text_field --namespace=customers
11
11
  ```
data/docs/onboarding.md CHANGED
@@ -13,29 +13,29 @@ The "user email" onboarding step is specifically used in situations where a user
13
13
 
14
14
  ## Relevant Files
15
15
 
16
- > TODO This section needs to be updated now that a bunch of these files are coming in from gems.
16
+ Each of the following files exist within their own respective Bullet Train packages. Make sure you navigate to the correct package when searching for the following files.
17
17
 
18
18
  ### Controllers
19
- - `ensure_onboarding_is_complete` in `app/controllers/account/application_controller.rb`
20
- - `app/controllers/account/onboarding/user_details_controller.rb`
21
- - `app/controllers/account/onboarding/user_email_controller.rb`
19
+ - `ensure_onboarding_is_complete` in `bullet_train/app/controllers/account/application_controller.rb`
20
+ - `bullet_train-base/app/controllers/account/onboarding/user_details_controller.rb`
21
+ - `bullet_train-base/app/controllers/account/onboarding/user_email_controller.rb`
22
22
 
23
23
  ### Views
24
- - `app/views/account/onboarding/user_details/edit.html.erb`
25
- - `app/views/account/onboarding/user_email/edit.html.erb`
24
+ - `bullet_train-base/app/views/account/onboarding/user_details/edit.html.erb`
25
+ - `bullet_train-base/app/views/account/onboarding/user_email/edit.html.erb`
26
26
 
27
27
  ### Models
28
- - `user#details_provided?` in `app/models/user.rb`
28
+ - `user#details_provided?` in `bullet_train-base/app/models/concerns/users/base.rb`
29
29
 
30
30
  ### Routes
31
- - `namespace :onboarding` in `config/routes.rb`
31
+ - `namespace :onboarding` in `bullet_train-base/config/routes.rb` and `bullet_train/config/routes.rb`
32
32
 
33
33
  ## Adding Additional Steps
34
34
  Although you can implement onboarding steps from scratch, we always just copy and paste one of the existing steps as a starting point, like so:
35
35
 
36
36
  1. Copy, rename, and modify of the existing onboarding controllers.
37
37
  2. Copy, rename, and modify the corresponding `edit.html.erb` view.
38
- 3. Copy and rename the route entry in `config/routes.rb`.
39
- 4. Add the appropriate gating logic in `ensure_onboarding_is_complete` in `app/controllers/account/application_controller.rb`
38
+ 3. Copy and rename the route entry in `bullet_train-base/config/routes.rb`.
39
+ 4. Add the appropriate gating logic in `ensure_onboarding_is_complete` in `bullet_train/app/controllers/account/application_controller.rb`
40
40
 
41
41
  Onboarding steps aren't limited to targeting `User` models. It's possible to add onboarding steps to help flesh out team `Membership` records or `Team` records as well. You can use this pattern for setting up any sort of required data for either the user or the team.
data/docs/overriding.md CHANGED
@@ -12,7 +12,7 @@ For this reason, common points of extension like framework-provided models and c
12
12
 
13
13
  ```
14
14
  class User < ApplicationRecord
15
- include Users::Core
15
+ include Users::Base
16
16
 
17
17
  # ...
18
18
  end
data/docs/permissions.md CHANGED
@@ -4,7 +4,7 @@
4
4
  Bullet Train leans heavily on [CanCanCan](https://github.com/CanCanCommunity/cancancan) for implementing authorization and permissions. (We’re also proud sponsors of its ongoing maintenance.) The original CanCan library by Ryan Bates was, in our opinion, a masterpiece and a software engineering marvel that has stood the test of time. It's truly a diamond among Ruby Gems. If you're not already familiar with CanCanCan, you should [read its documentation](https://github.com/CanCanCommunity/cancancan) to get familiar with its features and DSL.
5
5
 
6
6
  ## Bullet Train Roles
7
- Over many years of successfully implementing applications with CanCanCan, it became apparent to us that a supplemental level of abstraction could help streamline and simplify the definition of many common permissions, especially in large applications. We've since extracted this functionality into [a standalone Ruby Gem](https://github.com/bullet-train-co/bullet_train-roles) and moved the documentation that used to be here into [the README for that project](https://github.com/bullet-train-co/bullet_train-roles/blob/main/README.md). Should you encounter situations where this abstraction doesn't meet your specific needs, you can always implement the permissions you need using standard CanCanCan directives in `app/models/ability.rb`.
7
+ Over many years of successfully implementing applications with CanCanCan, it became apparent to us that a supplemental level of abstraction could help streamline and simplify the definition of many common permissions, especially in large applications. We've since extracted this functionality into [a standalone Ruby Gem](https://github.com/bullet-train-co/bullet_train-roles) and moved the documentation that used to be here into [the README for that project](https://github.com/bullet-train-co/bullet_train-roles). Should you encounter situations where this abstraction doesn't meet your specific needs, you can always implement the permissions you need using standard CanCanCan directives in `app/models/ability.rb`.
8
8
 
9
9
  ## Additional Notes
10
10