You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rails new -d sqlite --edge -j esbuild -c bootstrap .
155
155
```
156
156
157
157
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.
Copy file name to clipboardExpand all lines: README.md
+26-16Lines changed: 26 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,15 +31,25 @@ Some other nice things that `bootstrap_form` does for you are:
31
31
32
32
## Installation
33
33
34
-
Install Bootstrap 5. There are many ways to do this, depending on the asset pipeline you're using in your Rails application. One way is to use the gem that works with Sprockets. To do so, in a brand new Rails 7.0+ application created _without_ the `--webpacker` option, add the `bootstrap` gem to your `Gemfile`:
34
+
This gem needs Bootstrap. The gem itself doesn't really care how Bootstrap is included in your application. There are many ways to install Bootstrap in a Rails application. Covering them all is beyond the scope of this README. However, here are some hints for a couple of common options.
35
35
36
-
```ruby
37
-
gem "bootstrap", "~> 5.0"
36
+
If you're creating a new Rails app, create it with at least the following options:
37
+
38
+
```bash
39
+
rails new --javascript=esbuild --css=bootstrap <application-name>
38
40
```
39
41
40
-
And follow the remaining instructions in the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails) for setting up `application.scss` and `application.js`.
42
+
`esbuild` can be any of the options, _except_ the default `importmaps`.
43
+
44
+
If you have an existing project, and it's processing CSS and JavaScript with some sort of front-end preprocessor, then install Bootstrap for your front-end preprocessor. That's probably something like this:
41
45
42
-
Add the `bootstrap_form` gem to your `Gemfile`:
46
+
```bash
47
+
yarn add bootstrap popper.js
48
+
```
49
+
50
+
You can use this gem with other ways of installing Bootstrap, but how to do so is outside the scope of this README.
51
+
52
+
Once Bootstrap is installed, add the `bootstrap_form` gem to your `Gemfile`:
43
53
44
54
```ruby
45
55
gem "bootstrap_form", "~> 5.4"
@@ -49,28 +59,28 @@ Then:
49
59
50
60
`bundle install`
51
61
52
-
Depending on which CSS pre-processor you are using, adding the bootstrap form styles differs slightly.
53
-
If you use Rails in the default mode without any pre-processor, you'll have to add the following line to your `application.css` file:
54
-
55
-
```css
56
-
*= require rails_bootstrap_forms
57
-
```
58
-
59
-
If you followed the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails), you'll probably have switched to SCSS. In this case add the following line to your `application.scss`:
60
-
62
+
`bootstrap_form` uses a very small number of its own CSS styles. Add the styles to your CSS bundle (usually your `application.scss` file). The way to do this depends on whether you're using Propshaft (the Rails 8 default), or Sprockets (pre-Rails 8). (Check your `Gemfile` to see whether you're using `sprockets-rails` or `propshaft`.)
61
63
62
-
If you're using Propshaft (for example, the Rails 8 default), do it like this:
64
+
If you're using Propshaft, add the styles like this:
63
65
64
66
```scss
65
67
@use"rails_bootstrap_forms";
66
68
```
67
69
68
-
Else if you're using Sprockets (the Rails default before Rails 8), do it like this:
70
+
If you're using Sprockets, add the styles like this:
69
71
70
72
```scss
71
73
@import"rails_bootstrap_forms.css";
72
74
```
73
75
76
+
If you're using Sprockets, you can also consider using the `bootstrap` gem to your `Gemfile`, as a way of installing Bootstrap itself. However, we haven't used this approach for a few years. Please report an issue if it doesn't work:
77
+
78
+
```ruby
79
+
gem "bootstrap", "~> 5.0"
80
+
```
81
+
82
+
And follow the remaining instructions in the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails) for setting up `application.scss` and `application.js`.
0 commit comments