rails 4.0.13 → 4.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -17
- data/guides/CHANGELOG.md +68 -34
- data/guides/assets/images/edge_badge.png +0 -0
- data/guides/assets/images/feature_tile.gif +0 -0
- data/guides/assets/images/footer_tile.gif +0 -0
- data/guides/assets/images/fxn.png +0 -0
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/images/getting_started/challenge.png +0 -0
- data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/assets/images/getting_started/form_with_errors.png +0 -0
- data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/assets/images/getting_started/new_article.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/assets/images/header_tile.gif +0 -0
- data/guides/assets/images/icons/README +1 -1
- data/guides/assets/images/icons/callouts/11.png +0 -0
- data/guides/assets/images/icons/callouts/12.png +0 -0
- data/guides/assets/images/icons/callouts/13.png +0 -0
- data/guides/assets/images/icons/callouts/15.png +0 -0
- data/guides/assets/images/icons/caution.png +0 -0
- data/guides/assets/images/icons/example.png +0 -0
- data/guides/assets/images/radar.png +0 -0
- data/guides/assets/images/rails4_features.png +0 -0
- data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
- data/guides/assets/images/vijaydev.jpg +0 -0
- data/guides/assets/javascripts/guides.js +30 -34
- data/guides/assets/stylesheets/main.css +2 -1
- data/guides/assets/stylesheets/print.css +1 -1
- data/guides/bug_report_templates/action_controller_gem.rb +9 -4
- data/guides/bug_report_templates/action_controller_master.rb +4 -2
- data/guides/bug_report_templates/active_record_gem.rb +5 -2
- data/guides/bug_report_templates/active_record_master.rb +2 -1
- data/guides/bug_report_templates/generic_gem.rb +15 -0
- data/guides/bug_report_templates/generic_master.rb +26 -0
- data/guides/code/getting_started/Gemfile +21 -24
- data/guides/code/getting_started/Gemfile.lock +78 -73
- data/guides/code/getting_started/Rakefile +1 -1
- data/guides/code/getting_started/app/assets/javascripts/application.js +1 -2
- data/guides/code/getting_started/app/views/layouts/application.html.erb +2 -2
- data/guides/code/getting_started/config/environment.rb +1 -1
- data/guides/code/getting_started/config/environments/development.rb +2 -2
- data/guides/code/getting_started/config/environments/production.rb +3 -3
- data/guides/code/getting_started/config/environments/test.rb +2 -2
- data/guides/code/getting_started/config/initializers/secret_token.rb +1 -1
- data/guides/code/getting_started/config/initializers/session_store.rb +1 -1
- data/guides/code/getting_started/config/routes.rb +1 -1
- data/guides/code/getting_started/config.ru +1 -1
- data/guides/code/getting_started/public/404.html +2 -0
- data/guides/code/getting_started/public/422.html +2 -0
- data/guides/code/getting_started/public/500.html +2 -0
- data/guides/code/getting_started/test/test_helper.rb +0 -3
- data/guides/rails_guides/helpers.rb +3 -1
- data/guides/source/2_2_release_notes.md +2 -2
- data/guides/source/2_3_release_notes.md +8 -8
- data/guides/source/3_0_release_notes.md +2 -3
- data/guides/source/3_1_release_notes.md +2 -2
- data/guides/source/3_2_release_notes.md +12 -12
- data/guides/source/4_0_release_notes.md +79 -46
- data/guides/source/4_1_release_notes.md +731 -0
- data/guides/source/_welcome.html.erb +5 -2
- data/guides/source/action_controller_overview.md +189 -40
- data/guides/source/action_mailer_basics.md +27 -27
- data/guides/source/action_view_overview.md +131 -20
- data/guides/source/active_model_basics.md +6 -6
- data/guides/source/active_record_basics.md +15 -15
- data/guides/source/active_record_callbacks.md +18 -16
- data/guides/source/active_record_querying.md +93 -51
- data/guides/source/active_record_validations.md +26 -24
- data/guides/source/active_support_core_extensions.md +72 -118
- data/guides/source/active_support_instrumentation.md +13 -4
- data/guides/source/api_documentation_guidelines.md +104 -6
- data/guides/source/asset_pipeline.md +573 -244
- data/guides/source/association_basics.md +94 -22
- data/guides/source/caching_with_rails.md +15 -6
- data/guides/source/command_line.md +55 -46
- data/guides/source/configuring.md +248 -52
- data/guides/source/contributing_to_ruby_on_rails.md +18 -17
- data/guides/source/credits.html.erb +2 -2
- data/guides/source/debugging_rails_applications.md +39 -8
- data/guides/source/development_dependencies_install.md +91 -8
- data/guides/source/documents.yaml +4 -0
- data/guides/source/engines.md +678 -232
- data/guides/source/form_helpers.md +53 -35
- data/guides/source/generators.md +19 -15
- data/guides/source/getting_started.md +758 -497
- data/guides/source/i18n.md +64 -28
- data/guides/source/index.html.erb +1 -1
- data/guides/source/initialization.md +155 -58
- data/guides/source/kindle/toc.html.erb +1 -1
- data/guides/source/layout.html.erb +2 -2
- data/guides/source/layouts_and_rendering.md +59 -26
- data/guides/source/maintenance_policy.md +3 -3
- data/guides/source/migrations.md +101 -62
- data/guides/source/nested_model_forms.md +3 -3
- data/guides/source/plugins.md +34 -31
- data/guides/source/rails_application_templates.md +27 -8
- data/guides/source/rails_on_rack.md +41 -58
- data/guides/source/routing.md +115 -104
- data/guides/source/ruby_on_rails_guides_guidelines.md +2 -2
- data/guides/source/security.md +81 -36
- data/guides/source/testing.md +56 -79
- data/guides/source/upgrading_ruby_on_rails.md +531 -21
- data/guides/source/working_with_javascript_in_rails.md +19 -11
- metadata +51 -23
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
- data/guides/assets/images/getting_started/new_post.png +0 -0
- data/guides/assets/images/getting_started/post_with_comments.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_posts.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_posts_new.png +0 -0
- data/guides/assets/images/getting_started/undefined_method_post_path.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_posts.png +0 -0
- data/guides/assets/images/jaimeiniesta.jpg +0 -0
- data/guides/source/kindle/KINDLE.md +0 -26
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
The Rails Command Line
|
|
2
2
|
======================
|
|
3
3
|
|
|
4
|
-
Rails comes with every command line tool you'll need to
|
|
5
|
-
|
|
6
4
|
After reading this guide, you will know:
|
|
7
5
|
|
|
8
6
|
* How to create a Rails application.
|
|
@@ -27,6 +25,8 @@ There are a few commands that are absolutely critical to your everyday usage of
|
|
|
27
25
|
* `rails dbconsole`
|
|
28
26
|
* `rails new app_name`
|
|
29
27
|
|
|
28
|
+
All commands can run with ```-h or --help``` to list more information.
|
|
29
|
+
|
|
30
30
|
Let's create a simple Rails application to step through each of these commands in context.
|
|
31
31
|
|
|
32
32
|
### `rails new`
|
|
@@ -56,20 +56,18 @@ Rails will set you up with what seems like a huge amount of stuff for such a tin
|
|
|
56
56
|
|
|
57
57
|
The `rails server` command launches a small web server named WEBrick which comes bundled with Ruby. You'll use this any time you want to access your application through a web browser.
|
|
58
58
|
|
|
59
|
-
INFO: WEBrick isn't your only option for serving Rails. We'll get to that [later](#server-with-different-backends).
|
|
60
|
-
|
|
61
59
|
With no further work, `rails server` will run our new shiny Rails app:
|
|
62
60
|
|
|
63
61
|
```bash
|
|
64
62
|
$ cd commandsapp
|
|
65
|
-
$ rails server
|
|
63
|
+
$ bin/rails server
|
|
66
64
|
=> Booting WEBrick
|
|
67
|
-
=> Rails 4.
|
|
65
|
+
=> Rails 4.1.4 application starting in development on http://0.0.0.0:3000
|
|
68
66
|
=> Call with -d to detach
|
|
69
67
|
=> Ctrl-C to shutdown server
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
68
|
+
[2013-08-07 02:00:01] INFO WEBrick 1.3.1
|
|
69
|
+
[2013-08-07 02:00:01] INFO ruby 2.0.0 (2013-06-27) [x86_64-darwin11.2.0]
|
|
70
|
+
[2013-08-07 02:00:01] INFO WEBrick::HTTPServer#start: pid=69680 port=3000
|
|
73
71
|
```
|
|
74
72
|
|
|
75
73
|
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.
|
|
@@ -79,7 +77,7 @@ INFO: You can also use the alias "s" to start the server: `rails s`.
|
|
|
79
77
|
The server can be run on a different port using the `-p` option. The default development environment can be changed using `-e`.
|
|
80
78
|
|
|
81
79
|
```bash
|
|
82
|
-
$ rails server -e production -p 4000
|
|
80
|
+
$ bin/rails server -e production -p 4000
|
|
83
81
|
```
|
|
84
82
|
|
|
85
83
|
The `-b` option binds Rails to the specified IP, by default it is 0.0.0.0. You can run a server as a daemon by passing a `-d` option.
|
|
@@ -91,7 +89,7 @@ The `rails generate` command uses templates to create a whole lot of things. Run
|
|
|
91
89
|
INFO: You can also use the alias "g" to invoke the generator command: `rails g`.
|
|
92
90
|
|
|
93
91
|
```bash
|
|
94
|
-
$ rails generate
|
|
92
|
+
$ bin/rails generate
|
|
95
93
|
Usage: rails generate GENERATOR [args] [options]
|
|
96
94
|
|
|
97
95
|
...
|
|
@@ -116,7 +114,7 @@ Let's make our own controller with the controller generator. But what command sh
|
|
|
116
114
|
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`.
|
|
117
115
|
|
|
118
116
|
```bash
|
|
119
|
-
$ rails generate controller
|
|
117
|
+
$ bin/rails generate controller
|
|
120
118
|
Usage: rails generate controller NAME [action action] [options]
|
|
121
119
|
|
|
122
120
|
...
|
|
@@ -143,7 +141,7 @@ Example:
|
|
|
143
141
|
The controller generator is expecting parameters in the form of `generate controller ControllerName action1 action2`. Let's make a `Greetings` controller with an action of **hello**, which will say something nice to us.
|
|
144
142
|
|
|
145
143
|
```bash
|
|
146
|
-
$ rails generate controller Greetings hello
|
|
144
|
+
$ bin/rails generate controller Greetings hello
|
|
147
145
|
create app/controllers/greetings_controller.rb
|
|
148
146
|
route get "greetings/hello"
|
|
149
147
|
invoke erb
|
|
@@ -184,7 +182,7 @@ Then the view, to display our message (in `app/views/greetings/hello.html.erb`):
|
|
|
184
182
|
Fire up your server using `rails server`.
|
|
185
183
|
|
|
186
184
|
```bash
|
|
187
|
-
$ rails server
|
|
185
|
+
$ bin/rails server
|
|
188
186
|
=> Booting WEBrick...
|
|
189
187
|
```
|
|
190
188
|
|
|
@@ -195,7 +193,7 @@ INFO: With a normal, plain-old Rails application, your URLs will generally follo
|
|
|
195
193
|
Rails comes with a generator for data models too.
|
|
196
194
|
|
|
197
195
|
```bash
|
|
198
|
-
$ rails generate model
|
|
196
|
+
$ bin/rails generate model
|
|
199
197
|
Usage:
|
|
200
198
|
rails generate model NAME [field[:type][:index] field[:type][:index]] [options]
|
|
201
199
|
|
|
@@ -218,9 +216,9 @@ But instead of generating a model directly (which we'll be doing later), let's s
|
|
|
218
216
|
We will set up a simple resource called "HighScore" that will keep track of our highest score on video games we play.
|
|
219
217
|
|
|
220
218
|
```bash
|
|
221
|
-
$ rails generate scaffold HighScore game:string score:integer
|
|
219
|
+
$ bin/rails generate scaffold HighScore game:string score:integer
|
|
222
220
|
invoke active_record
|
|
223
|
-
create db/migrate/
|
|
221
|
+
create db/migrate/20130717151933_create_high_scores.rb
|
|
224
222
|
create app/models/high_score.rb
|
|
225
223
|
invoke test_unit
|
|
226
224
|
create test/models/high_score_test.rb
|
|
@@ -242,21 +240,24 @@ $ rails generate scaffold HighScore game:string score:integer
|
|
|
242
240
|
create app/helpers/high_scores_helper.rb
|
|
243
241
|
invoke test_unit
|
|
244
242
|
create test/helpers/high_scores_helper_test.rb
|
|
243
|
+
invoke jbuilder
|
|
244
|
+
create app/views/high_scores/index.json.jbuilder
|
|
245
|
+
create app/views/high_scores/show.json.jbuilder
|
|
245
246
|
invoke assets
|
|
246
247
|
invoke coffee
|
|
247
248
|
create app/assets/javascripts/high_scores.js.coffee
|
|
248
249
|
invoke scss
|
|
249
250
|
create app/assets/stylesheets/high_scores.css.scss
|
|
250
251
|
invoke scss
|
|
251
|
-
|
|
252
|
+
identical app/assets/stylesheets/scaffolds.css.scss
|
|
252
253
|
```
|
|
253
254
|
|
|
254
255
|
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.
|
|
255
256
|
|
|
256
|
-
The migration requires that we **migrate**, that is, run some Ruby code (living in that `
|
|
257
|
+
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 `rake db:migrate` command. We'll talk more about Rake in-depth in a little while.
|
|
257
258
|
|
|
258
259
|
```bash
|
|
259
|
-
$ rake db:migrate
|
|
260
|
+
$ bin/rake db:migrate
|
|
260
261
|
== CreateHighScores: migrating ===============================================
|
|
261
262
|
-- create_table(:high_scores)
|
|
262
263
|
-> 0.0017s
|
|
@@ -268,7 +269,7 @@ INFO: Let's talk about unit tests. Unit tests are code that tests and makes asse
|
|
|
268
269
|
Let's see the interface Rails created for us.
|
|
269
270
|
|
|
270
271
|
```bash
|
|
271
|
-
$ rails server
|
|
272
|
+
$ bin/rails server
|
|
272
273
|
```
|
|
273
274
|
|
|
274
275
|
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!)
|
|
@@ -282,14 +283,14 @@ INFO: You can also use the alias "c" to invoke the console: `rails c`.
|
|
|
282
283
|
You can specify the environment in which the `console` command should operate.
|
|
283
284
|
|
|
284
285
|
```bash
|
|
285
|
-
$ rails console staging
|
|
286
|
+
$ bin/rails console staging
|
|
286
287
|
```
|
|
287
288
|
|
|
288
289
|
If you wish to test out some code without changing any data, you can do that by invoking `rails console --sandbox`.
|
|
289
290
|
|
|
290
291
|
```bash
|
|
291
|
-
$ rails console --sandbox
|
|
292
|
-
Loading development environment in sandbox (Rails 4.
|
|
292
|
+
$ bin/rails console --sandbox
|
|
293
|
+
Loading development environment in sandbox (Rails 4.1.4)
|
|
293
294
|
Any modifications you make will be rolled back on exit
|
|
294
295
|
irb(main):001:0>
|
|
295
296
|
```
|
|
@@ -305,7 +306,7 @@ INFO: You can also use the alias "db" to invoke the dbconsole: `rails db`.
|
|
|
305
306
|
`runner` runs Ruby code in the context of Rails non-interactively. For instance:
|
|
306
307
|
|
|
307
308
|
```bash
|
|
308
|
-
$ rails runner "Model.long_running_method"
|
|
309
|
+
$ bin/rails runner "Model.long_running_method"
|
|
309
310
|
```
|
|
310
311
|
|
|
311
312
|
INFO: You can also use the alias "r" to invoke the runner: `rails r`.
|
|
@@ -313,7 +314,7 @@ INFO: You can also use the alias "r" to invoke the runner: `rails r`.
|
|
|
313
314
|
You can specify the environment in which the `runner` command should operate using the `-e` switch.
|
|
314
315
|
|
|
315
316
|
```bash
|
|
316
|
-
$ rails runner -e staging "Model.long_running_method"
|
|
317
|
+
$ bin/rails runner -e staging "Model.long_running_method"
|
|
317
318
|
```
|
|
318
319
|
|
|
319
320
|
### `rails destroy`
|
|
@@ -323,7 +324,7 @@ Think of `destroy` as the opposite of `generate`. It'll figure out what generate
|
|
|
323
324
|
INFO: You can also use the alias "d" to invoke the destroy command: `rails d`.
|
|
324
325
|
|
|
325
326
|
```bash
|
|
326
|
-
$ rails generate model Oops
|
|
327
|
+
$ bin/rails generate model Oops
|
|
327
328
|
invoke active_record
|
|
328
329
|
create db/migrate/20120528062523_create_oops.rb
|
|
329
330
|
create app/models/oops.rb
|
|
@@ -332,7 +333,7 @@ $ rails generate model Oops
|
|
|
332
333
|
create test/fixtures/oops.yml
|
|
333
334
|
```
|
|
334
335
|
```bash
|
|
335
|
-
$ rails destroy model Oops
|
|
336
|
+
$ bin/rails destroy model Oops
|
|
336
337
|
invoke active_record
|
|
337
338
|
remove db/migrate/20120528062523_create_oops.rb
|
|
338
339
|
remove app/models/oops.rb
|
|
@@ -348,8 +349,11 @@ Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'mak
|
|
|
348
349
|
|
|
349
350
|
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing `rake --tasks`. Each task has a description, and should help you find the thing you need.
|
|
350
351
|
|
|
352
|
+
To get the full backtrace for running rake task you can pass the option
|
|
353
|
+
```--trace``` to command line, for example ```rake db:create --trace```.
|
|
354
|
+
|
|
351
355
|
```bash
|
|
352
|
-
$ rake --tasks
|
|
356
|
+
$ bin/rake --tasks
|
|
353
357
|
rake about # List versions of all Rails frameworks and the environment
|
|
354
358
|
rake assets:clean # Remove compiled assets
|
|
355
359
|
rake assets:precompile # Compile all the assets named in config.assets.precompile
|
|
@@ -361,24 +365,26 @@ rake middleware # Prints out your Rack middleware stack
|
|
|
361
365
|
rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
|
|
362
366
|
rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids
|
|
363
367
|
```
|
|
368
|
+
INFO: You can also use ```rake -T``` to get the list of tasks.
|
|
364
369
|
|
|
365
370
|
### `about`
|
|
366
371
|
|
|
367
372
|
`rake 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.
|
|
368
373
|
|
|
369
374
|
```bash
|
|
370
|
-
$ rake about
|
|
375
|
+
$ bin/rake about
|
|
371
376
|
About your application's environment
|
|
372
377
|
Ruby version 1.9.3 (x86_64-linux)
|
|
373
378
|
RubyGems version 1.3.6
|
|
374
379
|
Rack version 1.3
|
|
375
|
-
Rails version 4.
|
|
380
|
+
Rails version 4.1.4
|
|
376
381
|
JavaScript Runtime Node.js (V8)
|
|
377
|
-
Active Record version 4.
|
|
378
|
-
Action Pack version 4.
|
|
379
|
-
Action
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
Active Record version 4.1.4
|
|
383
|
+
Action Pack version 4.1.4
|
|
384
|
+
Action View version 4.1.4
|
|
385
|
+
Action Mailer version 4.1.4
|
|
386
|
+
Active Support version 4.1.4
|
|
387
|
+
Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd131a7c88>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
|
|
382
388
|
Application root /home/foobar/commandsapp
|
|
383
389
|
Environment development
|
|
384
390
|
Database adapter sqlite3
|
|
@@ -408,7 +414,7 @@ The `doc:` namespace has the tools to generate documentation for your app, API d
|
|
|
408
414
|
`rake notes` will search through your code for comments beginning with FIXME, OPTIMIZE or TODO. The search is done in files with extension `.builder`, `.rb`, `.erb`, `.haml` and `.slim` for both default and custom annotations.
|
|
409
415
|
|
|
410
416
|
```bash
|
|
411
|
-
$ rake notes
|
|
417
|
+
$ bin/rake notes
|
|
412
418
|
(in /home/foobar/commandsapp)
|
|
413
419
|
app/controllers/admin/users_controller.rb:
|
|
414
420
|
* [ 20] [TODO] any other way to do this?
|
|
@@ -422,7 +428,7 @@ app/models/school.rb:
|
|
|
422
428
|
If you are looking for a specific annotation, say FIXME, you can use `rake notes:fixme`. Note that you have to lower case the annotation's name.
|
|
423
429
|
|
|
424
430
|
```bash
|
|
425
|
-
$ rake notes:fixme
|
|
431
|
+
$ bin/rake notes:fixme
|
|
426
432
|
(in /home/foobar/commandsapp)
|
|
427
433
|
app/controllers/admin/users_controller.rb:
|
|
428
434
|
* [132] high priority for next deploy
|
|
@@ -434,7 +440,7 @@ app/models/school.rb:
|
|
|
434
440
|
You can also use custom annotations in your code and list them using `rake notes:custom` by specifying the annotation using an environment variable `ANNOTATION`.
|
|
435
441
|
|
|
436
442
|
```bash
|
|
437
|
-
$ rake notes:custom ANNOTATION=BUG
|
|
443
|
+
$ bin/rake notes:custom ANNOTATION=BUG
|
|
438
444
|
(in /home/foobar/commandsapp)
|
|
439
445
|
app/models/post.rb:
|
|
440
446
|
* [ 23] Have to fix this one before pushing!
|
|
@@ -446,7 +452,7 @@ By default, `rake notes` will look in the `app`, `config`, `lib`, `bin` and `tes
|
|
|
446
452
|
|
|
447
453
|
```bash
|
|
448
454
|
$ export SOURCE_ANNOTATION_DIRECTORIES='spec,vendor'
|
|
449
|
-
$ rake notes
|
|
455
|
+
$ bin/rake notes
|
|
450
456
|
(in /home/foobar/commandsapp)
|
|
451
457
|
app/models/user.rb:
|
|
452
458
|
* [ 35] [FIXME] User should have a subscription at this point
|
|
@@ -462,18 +468,19 @@ spec/models/user_spec.rb:
|
|
|
462
468
|
|
|
463
469
|
INFO: A good description of unit testing in Rails is given in [A Guide to Testing Rails Applications](testing.html)
|
|
464
470
|
|
|
465
|
-
Rails comes with a test suite called
|
|
471
|
+
Rails comes with a test suite called Minitest. Rails owes its stability to the use of tests. The tasks available in the `test:` namespace helps in running the different tests you will hopefully write.
|
|
466
472
|
|
|
467
473
|
### `tmp`
|
|
468
474
|
|
|
469
475
|
The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like sessions (if you're using a file store for files), process id files, and cached actions.
|
|
470
476
|
|
|
471
|
-
The `tmp:` namespaced tasks will help you clear the `Rails.root/tmp` directory:
|
|
477
|
+
The `tmp:` namespaced tasks will help you clear and create the `Rails.root/tmp` directory:
|
|
472
478
|
|
|
473
479
|
* `rake tmp:cache:clear` clears `tmp/cache`.
|
|
474
480
|
* `rake tmp:sessions:clear` clears `tmp/sessions`.
|
|
475
481
|
* `rake tmp:sockets:clear` clears `tmp/sockets`.
|
|
476
482
|
* `rake tmp:clear` clears all the three: cache, sessions and sockets.
|
|
483
|
+
* `rake tmp:create` creates tmp directories for sessions, cache, sockets, and pids.
|
|
477
484
|
|
|
478
485
|
### Miscellaneous
|
|
479
486
|
|
|
@@ -483,7 +490,9 @@ The `tmp:` namespaced tasks will help you clear the `Rails.root/tmp` directory:
|
|
|
483
490
|
|
|
484
491
|
### Custom Rake Tasks
|
|
485
492
|
|
|
486
|
-
Custom rake tasks have a `.rake` extension and are placed in
|
|
493
|
+
Custom rake tasks have a `.rake` extension and are placed in
|
|
494
|
+
`Rails.root/lib/tasks`. You can create these custom rake tasks with the
|
|
495
|
+
`bin/rails generate task` command.
|
|
487
496
|
|
|
488
497
|
```ruby
|
|
489
498
|
desc "I am short, but comprehensive description for my cool task"
|
|
@@ -515,9 +524,9 @@ end
|
|
|
515
524
|
Invocation of the tasks will look like:
|
|
516
525
|
|
|
517
526
|
```bash
|
|
518
|
-
rake task_name
|
|
519
|
-
rake "task_name[value 1]" # entire argument string should be quoted
|
|
520
|
-
rake db:nothing
|
|
527
|
+
$ bin/rake task_name
|
|
528
|
+
$ bin/rake "task_name[value 1]" # entire argument string should be quoted
|
|
529
|
+
$ bin/rake db:nothing
|
|
521
530
|
```
|
|
522
531
|
|
|
523
532
|
NOTE: If your need to interact with your application models, perform database queries and so on, your task should depend on the `environment` task, which will load your application code.
|