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
Copy file name to clipboardExpand all lines: docs/oss/getting-started/installation-into-an-existing-rails-app.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Use this path when you already have a Rails application and want React on Rails
7
7
- Rails 7+ is recommended. Rails 5.2+ can work, but Webpacker-era apps usually need an incremental upgrade first.
8
8
- If your app still uses `webpacker`, expect this to be a two-step migration: move to `shakapacker`, then install React on Rails.
9
9
- If `bundle install` is already failing on older native gems such as `pg`, `nio4r`, `mysql2`, or `msgpack`, fix that baseline first. React on Rails installation cannot get past a broken app bundle.
10
-
- If your repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example: `"packageManager": "yarn@1.22.22"`.
10
+
- If your repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example for Yarn Classic: `npm pkg set packageManager="yarn@1.22.22"` (or add the field manually). Use the version that matches your project's Yarn installation.
11
11
- The install generator boots your app. Make sure `config/database.yml` exists and any required env vars for initializers are set before running `rails generate`.
12
12
- If your app is Rails 5 API-only, first [convert it to a standard Rails app](../migrating/convert-rails-5-api-only-app.md).
13
13
- Commit or stash your current work if you want the generated diff to be easier to review. The generator updates files like `bin/dev`, `config/shakapacker.yml`, routes, initializers, and sample views/controllers.
Copy file name to clipboardExpand all lines: docs/oss/migrating/migrating-from-react-rails.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Before swapping gems, check these first:
12
12
2.**Bundler age**: some older `react-rails` apps still carry Bundler 1.x lockfiles. Those can fail on modern Ruby before you even reach the migration work.
13
13
3.**Native gem age**: older lockfiles often pin `nio4r`, `pg`, or `mysql2` versions that fail to compile on current macOS and Ruby before the migration even starts.
14
14
4.**App boot readiness**: the React on Rails install generator boots the full Rails app. Make sure `config/database.yml` exists and required env vars for initializers are set.
15
-
5.**Package manager metadata**: if the repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example: `"packageManager": "yarn@1.22.22"`.
15
+
5.**Package manager metadata**: if the repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example for Yarn Classic: `npm pkg set packageManager="yarn@1.22.22"` (or add the field manually). Use the version that matches your project's Yarn installation.
16
16
6.**Rails age**: current `react_on_rails` requires Rails 5.2+. Rails 5.1 / Webpacker 3 apps are usually a staged migration, not a one-command migration.
17
17
18
18
If you are already on `shakapacker` 7+ and React 18+, the migration is mostly about helper syntax, component registration, and generated defaults.
@@ -29,7 +29,7 @@ If the first failure is a native gem compile error, solve that before swapping t
29
29
1. Update Deps
30
30
1. Replace `react-rails` in `Gemfile` with `react_on_rails` and make sure `shakapacker` is present.
31
31
2. Remove `react_ujs` from `package.json`.
32
-
3. If the repo uses Yarn and `package.json` does not already declare it, add `"packageManager": "yarn@1.22.22"`before booting the app with Shakapacker 9.
32
+
3. If the repo uses Yarn and `package.json` does not already declare it, add the package manager field before booting the app with Shakapacker 9: `npm pkg set packageManager="yarn@1.22.22"`(or add it manually to `package.json`). The example is for Yarn Classic; use the version that matches your project.
33
33
4. Run `bundle install` and your package manager's install command.
Copy file name to clipboardExpand all lines: docs/oss/migrating/migrating-from-vite-rails.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Before you start, make sure the current app still installs cleanly on the Ruby a
19
19
20
20
- If `bundle install` fails on older native gems such as `pg`, `nio4r`, `mysql2`, or `msgpack`, refresh those gems or use the Ruby version already pinned by the app before introducing React on Rails.
21
21
- If the app has an older Bundler-era lockfile, refresh that lockfile first.
22
-
- If the repo uses Yarn and has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example: `"packageManager": "yarn@1.22.22"`.
22
+
- If the repo uses Yarn and has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example for Yarn Classic: `npm pkg set packageManager="yarn@1.22.22"` (or add the field manually). Use the version that matches your project's Yarn installation.
23
23
- The React on Rails install generator boots the full app. Make sure `config/database.yml` exists and any required env vars for initializers are set before you run it.
24
24
- Commit or stash your current work so the generator diff is easier to review.
25
25
@@ -45,18 +45,27 @@ For anything beyond a tiny app, prefer a route-by-route cutover instead of a big
45
45
```bash
46
46
bundle add shakapacker --strict
47
47
bundle add react_on_rails --strict
48
-
bundle exec rails generate react_on_rails:install
49
48
```
50
49
51
-
If you use Yarn and `package.json` does not already declare it, set the package manager before running the generator:
50
+
## 2. Declare the package manager if needed
51
+
52
+
If you use Yarn and `package.json` does not already declare it, set the package manager before running the generator. This only updates `package.json`; it does not install or switch Yarn for you.
52
53
53
54
```bash
54
55
npm pkg set packageManager="yarn@1.22.22"
55
56
```
56
57
58
+
If you prefer, add the same field manually in `package.json`. The example above is for Yarn Classic; use the version that matches your project.
59
+
60
+
## 3. Run the generator
61
+
62
+
```bash
63
+
bundle exec rails generate react_on_rails:install
64
+
```
65
+
57
66
The generator adds the React on Rails initializer, `bin/dev`, Shakapacker config, example routes, and the server bundle entrypoint.
58
67
59
-
## 2. Replace Vite layout tags
68
+
## 4. Replace Vite layout tags
60
69
61
70
A typical Vite layout looks like this:
62
71
@@ -76,7 +85,7 @@ React on Rails + Shakapacker layouts use pack tags instead:
76
85
77
86
If you use React on Rails auto-bundling, keep those empty pack-tag placeholders in the layout and let React on Rails load component-specific bundles per page.
78
87
79
-
## 3. Move frontend code into the React on Rails structure
88
+
## 5. Move frontend code into the React on Rails structure
80
89
81
90
A common Vite layout is:
82
91
@@ -101,7 +110,7 @@ For auto-bundling, move page-level components into a `ror_components` directory,
Copy file name to clipboardExpand all lines: docs/oss/upgrading/upgrading-react-on-rails.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Before changing versions, check these first:
31
31
4.**Asset stack**: if the app still uses `webpacker`, upgrade to `shakapacker` first.
32
32
5.**Native gem age**: older `pg`, `nio4r`, `mysql2`, or `msgpack` versions can fail on current Ruby or macOS before the React on Rails upgrade even begins.
33
33
6.**App boot readiness**: the install generator boots the full Rails app. Make sure `config/database.yml` exists and required env vars for initializers are set.
34
-
7.**Package manager metadata**: if the repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example: `"packageManager": "yarn@1.22.22"`.
34
+
7.**Package manager metadata**: if the repo has a `yarn.lock` but no `"packageManager"` field in `package.json`, add one before introducing Shakapacker 9. Example for Yarn Classic: `npm pkg set packageManager="yarn@1.22.22"` (or add the field manually). Use the version that matches your project's Yarn installation.
35
35
8.**Version pinning**: use exact gem and npm package versions for React on Rails-related packages. Avoid `^`, `~`, or `*`.
36
36
37
37
If your app is both Ruby/Bundler-old and Webpacker-old, do those upgrades first. Trying to jump directly from a Rails 5 / Webpacker 3 / Bundler 1 stack to current React on Rails is usually more than one migration.
0 commit comments