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: guides/source/command_line.md
+34-34Lines changed: 34 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -114,18 +114,18 @@ If you wish to skip some files or components from being generated, you can appen
114
114
|`--skip-system-test`| Skip system test files |
115
115
|`--skip-bootsnap`| Skip bootsnap gem |
116
116
117
-
### `rails server`
117
+
### `bin/rails server`
118
118
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.
120
120
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:
122
122
123
123
```bash
124
124
$ cd commandsapp
125
125
$ bin/rails server
126
126
=> Booting Puma
127
127
=> 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
129
129
Puma starting in single mode...
130
130
* Version 3.12.1 (ruby 2.5.7-p206), codename: Llamas in Pajamas
131
131
* Min threads: 5, max threads: 5
@@ -136,7 +136,7 @@ Use Ctrl-C to stop
136
136
137
137
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.
138
138
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`.
140
140
141
141
The server can be run on a different port using the `-p` option. The default development environment can be changed using `-e`.
142
142
@@ -146,7 +146,7 @@ $ bin/rails server -e production -p 4000
146
146
147
147
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.
148
148
149
-
### `rails generate`
149
+
### `bin/rails generate`
150
150
151
151
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:
152
152
@@ -176,7 +176,7 @@ Using generators will save you a large amount of time by writing **boilerplate c
176
176
177
177
Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator:
178
178
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`.
180
180
181
181
```bash
182
182
$ bin/rails generate controller
@@ -240,7 +240,7 @@ Then the view, to display our message (in `app/views/greetings/hello.html.erb`):
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.
319
319
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.
321
321
322
322
```bash
323
323
$ bin/rails db:migrate
@@ -343,19 +343,19 @@ $ bin/rails server
343
343
344
344
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!)
345
345
346
-
### `rails console`
346
+
### `bin/rails console`
347
347
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.
349
349
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`.
351
351
352
352
You can specify the environment in which the `console` command should operate.
353
353
354
354
```bash
355
355
$ bin/rails console -e staging
356
356
```
357
357
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`.
359
359
360
360
```bash
361
361
$ bin/rails console --sandbox
@@ -366,7 +366,7 @@ irb(main):001:0>
366
366
367
367
#### The app and helper objects
368
368
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.
370
370
371
371
With the `app` method you can access named route helpers, as well as do requests.
372
372
@@ -389,21 +389,21 @@ With the `helper` method it is possible to access Rails and your application's h
389
389
=>"my custom helper"
390
390
```
391
391
392
-
### `rails dbconsole`
392
+
### `bin/rails dbconsole`
393
393
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.
395
395
396
396
INFO: You can also use the alias "db" to invoke the dbconsole: `bin/rails db`.
397
397
398
-
### `rails runner`
398
+
### `bin/rails runner`
399
399
400
400
`runner` runs Ruby code in the context of Rails non-interactively. For instance:
401
401
402
402
```bash
403
403
$ bin/rails runner "Model.long_running_method"
404
404
```
405
405
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`.
407
407
408
408
You can specify the environment in which the `runner` command should operate using the `-e` switch.
409
409
@@ -417,11 +417,11 @@ You can even execute ruby code written in a file with runner.
417
417
$ bin/rails runner lib/code_to_be_run.rb
418
418
```
419
419
420
-
### `rails destroy`
420
+
### `bin/rails destroy`
421
421
422
422
Think of `destroy` as the opposite of `generate`. It'll figure out what generate did, and undo it.
423
423
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`.
425
425
426
426
```bash
427
427
$ bin/rails generate model Oops
@@ -442,9 +442,9 @@ $ bin/rails destroy model Oops
442
442
remove test/fixtures/oops.yml
443
443
```
444
444
445
-
### `rails about`
445
+
### `bin/rails about`
446
446
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.
448
448
449
449
```bash
450
450
$ bin/rails about
@@ -461,21 +461,21 @@ Database adapter sqlite3
461
461
Database schema version 20180205173523
462
462
```
463
463
464
-
### `rails assets:`
464
+
### `bin/rails assets:`
465
465
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.
467
467
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`.
469
469
470
-
### `rails db:`
470
+
### `bin/rails db:`
471
471
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.
473
473
474
474
More information about migrations can be found in the [Migrations](active_record_migrations.html) guide.
475
475
476
-
### `rails notes`
476
+
### `bin/rails notes`
477
477
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.
479
479
480
480
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`.
`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.
583
583
584
-
### `rails test`
584
+
### `bin/rails test`
585
585
586
586
INFO: A good description of unit testing in Rails is given in [A Guide to Testing Rails Applications](testing.html)
587
587
588
588
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.
589
589
590
-
### `rails tmp:`
590
+
### `bin/rails tmp:`
591
591
592
592
The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like process id files and cached actions.
Copy file name to clipboardExpand all lines: guides/source/configuring.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ application. Accepts a valid day of week as a symbol (e.g. `:monday`).
77
77
78
78
* `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.
79
79
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:
81
81
82
82
```ruby
83
83
console do
@@ -439,7 +439,7 @@ All these configuration options are delegated to the `I18n` library.
439
439
Defaults to `false`.
440
440
441
441
*`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
443
443
having to send a query to the database to get this information.
444
444
Defaults to `true`.
445
445
@@ -1264,7 +1264,7 @@ By default Rails ships with three environments: "development", "test", and "prod
1264
1264
1265
1265
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.
1266
1266
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.
0 commit comments