Skip to content

Commit 2998672

Browse files
authored
Merge pull request rails#38789 from hahmed/docs/bin-rails-updates
Remove reference to global rails command
2 parents 9176c36 + 6504e97 commit 2998672

File tree

15 files changed

+74
-110
lines changed

15 files changed

+74
-110
lines changed

activerecord/lib/active_record/fixtures.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc:
447447
# It's possible to set the fixture's model class directly in the YAML file.
448448
# This is helpful when fixtures are loaded outside tests and
449449
# +set_fixture_class+ is not available (e.g.
450-
# when running <tt>rails db:fixtures:load</tt>).
450+
# when running <tt>bin/rails db:fixtures:load</tt>).
451451
#
452452
# _fixture:
453453
# model_class: User

activerecord/lib/active_record/railties/databases.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ db_namespace = namespace :db do
329329
pending_migrations.each do |pending_migration|
330330
puts " %4d %s" % [pending_migration.version, pending_migration.name]
331331
end
332-
abort %{Run `rails db:migrate:#{name}` to update your database then try again.}
332+
abort %{Run `bin/rails db:migrate:#{name}` to update your database then try again.}
333333
end
334334
end
335335
end

guides/source/active_record_multiple_databases.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ connection specification name.
133133
Now that we have the `database.yml` and the new model set up it's time to create the databases.
134134
Rails 6.0 ships with all the rails tasks you need to use multiple databases in Rails.
135135

136-
You can run `rails -T` to see all the commands you're able to run. You should see the following:
136+
You can run `bin/rails -T` to see all the commands you're able to run. You should see the following:
137137

138138
```bash
139-
$ rails -T
139+
$ bin/rails -T
140140
rails db:create # Creates the database from DATABASE_URL or config/database.yml for the ...
141141
rails db:create:animals # Create animals database for current environment
142142
rails db:create:primary # Create primary database for current environment
@@ -166,10 +166,10 @@ rails db:structure:load:animals # Recreates the animals database from t
166166
rails db:structure:load:primary # Recreates the primary database from the structure.sql file
167167
```
168168

169-
Running a command like `rails db:create` will create both the primary and animals databases.
169+
Running a command like `bin/rails db:create` will create both the primary and animals databases.
170170
Note that there is no command for creating the users and you'll need to do that manually
171171
to support the readonly users for your replicas. If you want to create just the animals
172-
database you can run `rails db:create:animals`.
172+
database you can run `bin/rails db:create:animals`.
173173

174174
## Migrations
175175

guides/source/command_line.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ If you wish to skip some files or components from being generated, you can appen
114114
| `--skip-system-test` | Skip system test files |
115115
| `--skip-bootsnap` | Skip bootsnap gem |
116116

117-
### `rails server`
117+
### `bin/rails server`
118118

119-
The `rails server` command launches a web server named Puma which comes bundled with Rails. You'll use this any time you want to access your application through a web browser.
119+
The `bin/rails server` command launches a web server named Puma which comes bundled with Rails. You'll use this any time you want to access your application through a web browser.
120120

121-
With no further work, `rails server` will run our new shiny Rails app:
121+
With no further work, `bin/rails server` will run our new shiny Rails app:
122122

123123
```bash
124124
$ cd commandsapp
125125
$ bin/rails server
126126
=> Booting Puma
127127
=> Rails 6.0.0 application starting in development
128-
=> Run `rails server --help` for more startup options
128+
=> Run `bin/rails server --help` for more startup options
129129
Puma starting in single mode...
130130
* Version 3.12.1 (ruby 2.5.7-p206), codename: Llamas in Pajamas
131131
* Min threads: 5, max threads: 5
@@ -136,7 +136,7 @@ Use Ctrl-C to stop
136136

137137
With just three commands we whipped up a Rails server listening on port 3000. Go to your browser and open [http://localhost:3000](http://localhost:3000), you will see a basic Rails app running.
138138

139-
INFO: You can also use the alias "s" to start the server: `rails s`.
139+
INFO: You can also use the alias "s" to start the server: `bin/rails s`.
140140

141141
The server can be run on a different port using the `-p` option. The default development environment can be changed using `-e`.
142142

@@ -146,7 +146,7 @@ $ bin/rails server -e production -p 4000
146146

147147
The `-b` option binds Rails to the specified IP, by default it is localhost. You can run a server as a daemon by passing a `-d` option.
148148

149-
### `rails generate`
149+
### `bin/rails generate`
150150

151151
The `bin/rails generate` command uses templates to create a whole lot of things. Running `bin/rails generate` by itself gives a list of available generators:
152152

@@ -176,7 +176,7 @@ Using generators will save you a large amount of time by writing **boilerplate c
176176

177177
Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator:
178178

179-
INFO: All Rails console utilities have help text. As with most *nix utilities, you can try adding `--help` or `-h` to the end, for example `rails server --help`.
179+
INFO: All Rails console utilities have help text. As with most *nix utilities, you can try adding `--help` or `-h` to the end, for example `bin/rails server --help`.
180180

181181
```bash
182182
$ bin/rails generate controller
@@ -240,7 +240,7 @@ Then the view, to display our message (in `app/views/greetings/hello.html.erb`):
240240
<p><%= @message %></p>
241241
```
242242

243-
Fire up your server using `rails server`.
243+
Fire up your server using `bin/rails server`.
244244

245245
```bash
246246
$ bin/rails server
@@ -317,7 +317,7 @@ $ bin/rails generate scaffold HighScore game:string score:integer
317317
318318
The generator checks that there exist the directories for models, controllers, helpers, layouts, functional and unit tests, stylesheets, creates the views, controller, model and database migration for HighScore (creating the `high_scores` table and fields), takes care of the route for the **resource**, and new tests for everything.
319319
320-
The migration requires that we **migrate**, that is, run some Ruby code (living in that `20130717151933_create_high_scores.rb`) to modify the schema of our database. Which database? The SQLite3 database that Rails will create for you when we run the `rails db:migrate` command. We'll talk more about that command below.
320+
The migration requires that we **migrate**, that is, run some Ruby code (living in that `20130717151933_create_high_scores.rb`) to modify the schema of our database. Which database? The SQLite3 database that Rails will create for you when we run the `bin/rails db:migrate` command. We'll talk more about that command below.
321321
322322
```bash
323323
$ bin/rails db:migrate
@@ -343,19 +343,19 @@ $ bin/rails server
343343
344344
Go to your browser and open [http://localhost:3000/high_scores](http://localhost:3000/high_scores), now we can create new high scores (55,160 on Space Invaders!)
345345
346-
### `rails console`
346+
### `bin/rails console`
347347
348-
The `console` command lets you interact with your Rails application from the command line. On the underside, `rails console` uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
348+
The `console` command lets you interact with your Rails application from the command line. On the underside, `bin/rails console` uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
349349
350-
INFO: You can also use the alias "c" to invoke the console: `rails c`.
350+
INFO: You can also use the alias "c" to invoke the console: `bin/rails c`.
351351
352352
You can specify the environment in which the `console` command should operate.
353353
354354
```bash
355355
$ bin/rails console -e staging
356356
```
357357
358-
If you wish to test out some code without changing any data, you can do that by invoking `rails console --sandbox`.
358+
If you wish to test out some code without changing any data, you can do that by invoking `bin/rails console --sandbox`.
359359
360360
```bash
361361
$ bin/rails console --sandbox
@@ -366,7 +366,7 @@ irb(main):001:0>
366366
367367
#### The app and helper objects
368368
369-
Inside the `rails console` you have access to the `app` and `helper` instances.
369+
Inside the `bin/rails console` you have access to the `app` and `helper` instances.
370370
371371
With the `app` method you can access named route helpers, as well as do requests.
372372
@@ -389,21 +389,21 @@ With the `helper` method it is possible to access Rails and your application's h
389389
=> "my custom helper"
390390
```
391391
392-
### `rails dbconsole`
392+
### `bin/rails dbconsole`
393393
394-
`rails dbconsole` figures out which database you're using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL (including MariaDB), PostgreSQL, and SQLite3.
394+
`bin/rails dbconsole` figures out which database you're using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL (including MariaDB), PostgreSQL, and SQLite3.
395395
396396
INFO: You can also use the alias "db" to invoke the dbconsole: `bin/rails db`.
397397
398-
### `rails runner`
398+
### `bin/rails runner`
399399
400400
`runner` runs Ruby code in the context of Rails non-interactively. For instance:
401401
402402
```bash
403403
$ bin/rails runner "Model.long_running_method"
404404
```
405405
406-
INFO: You can also use the alias "r" to invoke the runner: `rails r`.
406+
INFO: You can also use the alias "r" to invoke the runner: `bin/rails r`.
407407
408408
You can specify the environment in which the `runner` command should operate using the `-e` switch.
409409
@@ -417,11 +417,11 @@ You can even execute ruby code written in a file with runner.
417417
$ bin/rails runner lib/code_to_be_run.rb
418418
```
419419
420-
### `rails destroy`
420+
### `bin/rails destroy`
421421
422422
Think of `destroy` as the opposite of `generate`. It'll figure out what generate did, and undo it.
423423
424-
INFO: You can also use the alias "d" to invoke the destroy command: `rails d`.
424+
INFO: You can also use the alias "d" to invoke the destroy command: `bin/rails d`.
425425
426426
```bash
427427
$ bin/rails generate model Oops
@@ -442,9 +442,9 @@ $ bin/rails destroy model Oops
442442
remove test/fixtures/oops.yml
443443
```
444444
445-
### `rails about`
445+
### `bin/rails about`
446446
447-
`rails about` gives information about version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application's folder, the current Rails environment name, your app's database adapter, and schema version. It is useful when you need to ask for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation.
447+
`bin/rails about` gives information about version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application's folder, the current Rails environment name, your app's database adapter, and schema version. It is useful when you need to ask for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation.
448448
449449
```bash
450450
$ bin/rails about
@@ -461,21 +461,21 @@ Database adapter sqlite3
461461
Database schema version 20180205173523
462462
```
463463
464-
### `rails assets:`
464+
### `bin/rails assets:`
465465
466-
You can precompile the assets in `app/assets` using `rails assets:precompile`, and remove older compiled assets using `rails assets:clean`. The `assets:clean` command allows for rolling deploys that may still be linking to an old asset while the new assets are being built.
466+
You can precompile the assets in `app/assets` using `bin/rails assets:precompile`, and remove older compiled assets using `bin/rails assets:clean`. The `assets:clean` command allows for rolling deploys that may still be linking to an old asset while the new assets are being built.
467467
468-
If you want to clear `public/assets` completely, you can use `rails assets:clobber`.
468+
If you want to clear `public/assets` completely, you can use `bin/rails assets:clobber`.
469469
470-
### `rails db:`
470+
### `bin/rails db:`
471471
472-
The most common commands of the `db:` rails namespace are `migrate` and `create`, and it will pay off to try out all of the migration rails commands (`up`, `down`, `redo`, `reset`). `rails db:version` is useful when troubleshooting, telling you the current version of the database.
472+
The most common commands of the `db:` rails namespace are `migrate` and `create`, and it will pay off to try out all of the migration rails commands (`up`, `down`, `redo`, `reset`). `bin/rails db:version` is useful when troubleshooting, telling you the current version of the database.
473473
474474
More information about migrations can be found in the [Migrations](active_record_migrations.html) guide.
475475
476-
### `rails notes`
476+
### `bin/rails notes`
477477
478-
`rails notes` searches through your code for comments beginning with a specific keyword. You can refer to `rails notes --help` for information about usage.
478+
`bin/rails notes` searches through your code for comments beginning with a specific keyword. You can refer to `bin/rails notes --help` for information about usage.
479479
480480
By default, it will search in `app`, `config`, `db`, `lib`, and `test` directories for FIXME, OPTIMIZE, and TODO annotations in files with extension `.builder`, `.rb`, `.rake`, `.yml`, `.yaml`, `.ruby`, `.css`, `.js`, and `.erb`.
481481
@@ -514,7 +514,7 @@ config.annotations.register_tags("DEPRECATEME", "TESTME")
514514
```
515515
516516
```bash
517-
$ rails notes
517+
$ bin/rails notes
518518
app/controllers/admin/users_controller.rb:
519519
* [ 20] [TODO] do A/B testing on this
520520
* [ 42] [TESTME] this needs more functional tests
@@ -577,17 +577,17 @@ vendor/tools.rb:
577577
* [ 56] [TODO] Get rid of this dependency
578578
```
579579
580-
### `rails routes`
580+
### `bin/rails routes`
581581
582-
`rails routes` will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.
582+
`bin/rails routes` will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.
583583
584-
### `rails test`
584+
### `bin/rails test`
585585
586586
INFO: A good description of unit testing in Rails is given in [A Guide to Testing Rails Applications](testing.html)
587587
588588
Rails comes with a test framework called minitest. Rails owes its stability to the use of tests. The commands available in the `test:` namespace helps in running the different tests you will hopefully write.
589589
590-
### `rails tmp:`
590+
### `bin/rails tmp:`
591591
592592
The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like process id files and cached actions.
593593

guides/source/configuring.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ application. Accepts a valid day of week as a symbol (e.g. `:monday`).
7777
7878
* `config.consider_all_requests_local` is a flag. If `true` then any error will cause detailed debugging information to be dumped in the HTTP response, and the `Rails::Info` controller will show the application runtime context in `/rails/info/properties`. `true` by default in development and test environments, and `false` in production mode. For finer-grained control, set this to `false` and implement `show_detailed_exceptions?` in controllers to specify which requests should provide debugging information on errors.
7979
80-
* `config.console` allows you to set class that will be used as console you run `rails console`. It's best to run it in `console` block:
80+
* `config.console` allows you to set class that will be used as console you run `bin/rails console`. It's best to run it in `console` block:
8181

8282
```ruby
8383
console do
@@ -439,7 +439,7 @@ All these configuration options are delegated to the `I18n` library.
439439
Defaults to `false`.
440440

441441
* `config.active_record.use_schema_cache_dump` enables users to get schema cache information
442-
from `db/schema_cache.yml` (generated by `rails db:schema:cache:dump`), instead of
442+
from `db/schema_cache.yml` (generated by `bin/rails db:schema:cache:dump`), instead of
443443
having to send a query to the database to get this information.
444444
Defaults to `true`.
445445

@@ -1264,7 +1264,7 @@ By default Rails ships with three environments: "development", "test", and "prod
12641264
12651265
Imagine you have a server which mirrors the production environment but is only used for testing. Such a server is commonly called a "staging server". To define an environment called "staging" for this server, just create a file called `config/environments/staging.rb`. Please use the contents of any existing file in `config/environments` as a starting point and make the necessary changes from there.
12661266
1267-
That environment is no different than the default ones, start a server with `rails server -e staging`, a console with `rails console -e staging`, `Rails.env.staging?` works, etc.
1267+
That environment is no different than the default ones, start a server with `bin/rails server -e staging`, a console with `bin/rails console -e staging`, `Rails.env.staging?` works, etc.
12681268
12691269
12701270
### Deploy to a Subdirectory (relative URL root)

guides/source/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ tells Rails to map requests to <http://localhost:3000/welcome/index> to the
405405
welcome controller's index action. This was created earlier when you ran the
406406
controller generator (`bin/rails generate controller Welcome index`).
407407

408-
Launch the web server again if you stopped it to generate the controller (`rails
408+
Launch the web server again if you stopped it to generate the controller (`bin/rails
409409
server`) and navigate to <http://localhost:3000> in your browser. You'll see the
410410
"Hello, Rails!" message you put into `app/views/welcome/index.html.erb`,
411411
indicating that this new route is indeed going to `WelcomeController`'s `index`

0 commit comments

Comments
 (0)