File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
1212
13- _ 1368 TILs and counting..._
13+ _ 1369 TILs and counting..._
1414
1515---
1616
@@ -899,6 +899,7 @@ _1368 TILs and counting..._
899899- [ Rollback A Specific Migration Out Of Order] ( rails/rollback-a-specific-migration-out-of-order.md )
900900- [ Rounding Numbers With Precision] ( rails/rounding-numbers-with-precision.md )
901901- [ Run A Rake Task Programmatically] ( rails/run-a-rake-task-programmatically.md )
902+ - [ Run Commands With Specific Rails Version] ( rails/run-commands-with-specific-rails-version.md )
902903- [ Run Some Code Whenever Rails Console Starts] ( rails/run-some-code-whenever-rails-console-starts.md )
903904- [ Schedule Sidekiq Jobs Out Into The Future] ( rails/schedule-sidekiq-jobs-out-into-the-future.md )
904905- [ Secure Passwords With Rails And Bcrypt] ( rails/secure-passwords-with-rails-and-bcrypt.md )
Original file line number Diff line number Diff line change 1+ # Run Commands With Specific Rails Version
2+
3+ You can have multiple versions of a gem like ` rails ` installed with ` gem ` .
4+ However, when you go to run a rails command, your system will default to using
5+ the latest version that you have installed.
6+
7+ So doing a version check will show that version to currently be ` 7.1.3 ` and
8+ running something like ` rails new ` will set up a new Rails 7.1.3 app.
9+
10+ ``` bash
11+ $ rails --version
12+ Rails 7.1.3
13+
14+ $ rails new my_app
15+ ```
16+
17+ If you want to use a Rails version besides the latest you have installed for
18+ whatever command, you can use a ` gem ` convention which is to put ` _<VERSION>_ `
19+ right after the gem name.
20+
21+ Let's try this for Rails 6.1.3:
22+
23+ ``` bash
24+ $ rails _6.1.3_ --version
25+ Rails 6.1.3
26+
27+ $ rails _6.1.3_ new my_app
28+ ```
29+
30+ [ source] ( https://stackoverflow.com/a/452458/535590 )
You can’t perform that action at this time.
0 commit comments