Skip to content

Commit 65b8286

Browse files
committed
Regular Maintenance.
1 parent 1b0d267 commit 65b8286

10 files changed

+107
-55
lines changed

source/command_line.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ $ bin/rails generate controller Greetings hello
149149
create test/controllers/greetings_controller_test.rb
150150
invoke helper
151151
create app/helpers/greetings_helper.rb
152-
invoke test_unit
153-
create test/helpers/greetings_helper_test.rb
154152
invoke assets
155153
invoke coffee
156154
create app/assets/javascripts/greetings.js.coffee
@@ -236,8 +234,6 @@ $ bin/rails generate scaffold HighScore game:string score:integer
236234
create test/controllers/high_scores_controller_test.rb
237235
invoke helper
238236
create app/helpers/high_scores_helper.rb
239-
invoke test_unit
240-
create test/helpers/high_scores_helper_test.rb
241237
invoke jbuilder
242238
create app/views/high_scores/index.json.jbuilder
243239
create app/views/high_scores/show.json.jbuilder

source/configuring.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ numbers. New applications filter out passwords by adding the following `config.f
137137
* `config.assets.enabled` a flag that controls whether the asset
138138
pipeline is enabled. It is set to true by default.
139139
140-
*`config.assets.raise_runtime_errors`* Set this flag to `true` to enable additional runtime error checking. Recommended in `config/environments/development.rb` to minimize unexpected behavior when deploying to `production`.
140+
* `config.assets.raise_runtime_errors`* Set this flag to `true` to enable additional runtime error checking. Recommended in `config/environments/development.rb` to minimize unexpected behavior when deploying to `production`.
141141
142142
* `config.assets.compress` a flag that enables the compression of compiled assets. It is explicitly set to true in `config/environments/production.rb`.
143143
@@ -151,6 +151,8 @@ pipeline is enabled. It is set to true by default.
151151
152152
* `config.assets.prefix` defines the prefix where assets are served from. Defaults to `/assets`.
153153
154+
* `config.assets.manifest` defines the full path to be used for the asset precompiler's manifest file. Defaults to a file named `manifest-<random>.json` in the `config.assets.prefix` directory within the public folder.
155+
154156
* `config.assets.digest` enables the use of MD5 fingerprints in asset names. Set to `true` by default in `production.rb`.
155157

156158
* `config.assets.debug` disables the concatenation and compression of assets. Set to `true` by default in `development.rb`.
@@ -996,3 +998,24 @@ If you get the above error, you might want to increase the size of connection
996998
pool by incrementing the `pool` option in `database.yml`
997999

9981000
NOTE. If you are running in a multi-threaded environment, there could be a chance that several threads may be accessing multiple connections simultaneously. So depending on your current request load, you could very well have multiple threads contending for a limited amount of connections.
1001+
1002+
1003+
Custom configuration
1004+
--------------------
1005+
1006+
You can configure your own code through the Rails configuration object with custom configuration. It works like this:
1007+
1008+
```ruby
1009+
config.x.payment_processing.schedule = :daily
1010+
config.x.payment_processing.retries = 3
1011+
config.x.super_debugger = true
1012+
```
1013+
1014+
These configuration points are then available through the configuration object:
1015+
1016+
```ruby
1017+
Rails.configuration.x.payment_processing.schedule # => :daily
1018+
Rails.configuration.x.payment_processing.retries # => 3
1019+
Rails.configuration.x.super_debugger # => true
1020+
Rails.configuration.x.super_debugger.not_set # => nil
1021+
```

source/engines.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ following to the dummy application's routes file at
136136
`test/dummy/config/routes.rb`:
137137

138138
```ruby
139-
mount Blorgh::Engine, at: "blorgh"
139+
mount Blorgh::Engine => "/blorgh"
140140
```
141141

142142
### Inside an Engine
@@ -173,7 +173,7 @@ Within `lib/blorgh/engine.rb` is the base class for the engine:
173173

174174
```ruby
175175
module Blorgh
176-
class Engine < Rails::Engine
176+
class Engine < ::Rails::Engine
177177
isolate_namespace Blorgh
178178
end
179179
end
@@ -322,8 +322,6 @@ invoke test_unit
322322
create test/controllers/blorgh/articles_controller_test.rb
323323
invoke helper
324324
create app/helpers/blorgh/articles_helper.rb
325-
invoke test_unit
326-
create test/helpers/blorgh/articles_helper_test.rb
327325
invoke assets
328326
invoke js
329327
create app/assets/javascripts/blorgh/articles.js
@@ -560,8 +558,6 @@ invoke test_unit
560558
create test/controllers/blorgh/comments_controller_test.rb
561559
invoke helper
562560
create app/helpers/blorgh/comments_helper.rb
563-
invoke test_unit
564-
create test/helpers/blorgh/comments_helper_test.rb
565561
invoke assets
566562
invoke js
567563
create app/assets/javascripts/blorgh/comments.js

source/generators.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ $ bin/rails generate scaffold User name:string
191191
create test/controllers/users_controller_test.rb
192192
invoke helper
193193
create app/helpers/users_helper.rb
194-
invoke test_unit
195-
create test/helpers/users_helper_test.rb
196194
invoke jbuilder
197195
create app/views/users/index.json.jbuilder
198196
create app/views/users/show.json.jbuilder
@@ -387,8 +385,6 @@ $ bin/rails generate scaffold Comment body:text
387385
create test/controllers/comments_controller_test.rb
388386
invoke my_helper
389387
create app/helpers/comments_helper.rb
390-
invoke shoulda
391-
create test/helpers/comments_helper_test.rb
392388
invoke jbuilder
393389
create app/views/comments/index.json.jbuilder
394390
create app/views/comments/show.json.jbuilder

source/getting_started.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,15 @@ following in the `blog` directory:
191191
$ bin/rails server
192192
```
193193

194-
TIP: Compiling CoffeeScript to JavaScript requires a JavaScript runtime and the
195-
absence of a runtime will give you an `execjs` error. Usually Mac OS X and
196-
Windows come with a JavaScript runtime installed. Rails adds the `therubyracer`
197-
gem to the generated `Gemfile` in a commented line for new apps and you can
198-
uncomment if you need it. `therubyrhino` is the recommended runtime for JRuby
199-
users and is added by default to the `Gemfile` in apps generated under JRuby.
200-
You can investigate about all the supported runtimes at
201-
[ExecJS](https://github.com/sstephenson/execjs#readme).
194+
TIP: Compiling CoffeeScript and JavaScript asset compression requires you
195+
have a JavaScript runtime available on your system, in the absence
196+
of a runtime you will see an `execjs` error during asset compilation.
197+
Usually Mac OS X and Windows come with a JavaScript runtime installed.
198+
Rails adds the `therubyracer` gem to the generated `Gemfile` in a
199+
commented line for new apps and you can uncomment if you need it.
200+
`therubyrhino` is the recommended runtime for JRuby users and is added by
201+
default to the `Gemfile` in apps generated under JRuby. You can investigate
202+
about all the supported runtimes at [ExecJS](https://github.com/sstephenson/execjs#readme).
202203

203204
This will fire up WEBrick, a web server distributed with Ruby by default. To see
204205
your application in action, open a browser window and navigate to
@@ -256,8 +257,6 @@ invoke test_unit
256257
create test/controllers/welcome_controller_test.rb
257258
invoke helper
258259
create app/helpers/welcome_helper.rb
259-
invoke test_unit
260-
create test/helpers/welcome_helper_test.rb
261260
invoke assets
262261
invoke coffee
263262
create app/assets/javascripts/welcome.js.coffee
@@ -1636,7 +1635,6 @@ This creates six files and one empty directory:
16361635
| app/views/comments/ | Views of the controller are stored here |
16371636
| test/controllers/comments_controller_test.rb | The test for the controller |
16381637
| app/helpers/comments_helper.rb | A view helper file |
1639-
| test/helpers/comments_helper_test.rb | The test for the helper |
16401638
| app/assets/javascripts/comment.js.coffee | CoffeeScript for the controller |
16411639
| app/assets/stylesheets/comment.css.scss | Cascading style sheet for the controller |
16421640

source/plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $ bin/rails plugin new yaffle
4545
See usage and options by asking for help:
4646

4747
```bash
48-
$ bin/rails plugin --help
48+
$ bin/rails plugin new --help
4949
```
5050

5151
Testing Your Newly Generated Plugin
@@ -440,5 +440,5 @@ $ bin/rake rdoc
440440

441441
* [Developing a RubyGem using Bundler](https://github.com/radar/guides/blob/master/gem-development.md)
442442
* [Using .gemspecs as Intended](http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/)
443-
* [Gemspec Reference](http://docs.rubygems.org/read/chapter/20)
443+
* [Gemspec Reference](http://guides.rubygems.org/specification-reference/)
444444
* [GemPlugins: A Brief Introduction to the Future of Rails Plugins](http://www.intridea.com/blog/2008/6/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins)

source/rails_application_templates.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ generate(:scaffold, "person name:string")
3838
route "root to: 'people#index'"
3939
rake("db:migrate")
4040

41-
git :init
42-
git add: "."
43-
git commit: %Q{ -m 'Initial commit' }
41+
after_bundle do
42+
git :init
43+
git add: "."
44+
git commit: %Q{ -m 'Initial commit' }
45+
end
4446
```
4547

4648
The following sections outline the primary methods provided by the API:
@@ -228,6 +230,22 @@ git add: "."
228230
git commit: "-a -m 'Initial commit'"
229231
```
230232

233+
### after_bundle(&block)
234+
235+
Registers a callback to be executed after the gems are bundled and binstubs
236+
are generated. Useful for all generated files to version control:
237+
238+
```ruby
239+
after_bundle do
240+
git :init
241+
git add: '.'
242+
git commit: "-a -m 'Initial commit'"
243+
end
244+
```
245+
246+
The callbacks gets executed even if `--skip-bundle` and/or `--skip-spring` has
247+
been passed.
248+
231249
Advanced Usage
232250
--------------
233251

source/ruby_on_rails_guides_guidelines.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ After reading this guide, you will know:
1313
Markdown
1414
-------
1515

16-
Guides are written in [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown). There is comprehensive [documentation for Markdown](http://daringfireball.net/projects/markdown/syntax), a [cheatsheet](http://daringfireball.net/projects/markdown/basics).
16+
Guides are written in [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown). There is comprehensive [documentation for Markdown](http://daringfireball.net/projects/markdown/syntax), as well as a [cheatsheet](http://daringfireball.net/projects/markdown/basics).
1717

1818
Prologue
1919
--------
2020

21-
Each guide should start with motivational text at the top (that's the little introduction in the blue area). The prologue should tell the reader what the guide is about, and what they will learn. See for example the [Routing Guide](routing.html).
21+
Each guide should start with motivational text at the top (that's the little introduction in the blue area). The prologue should tell the reader what the guide is about, and what they will learn. As an example, see the [Routing Guide](routing.html).
2222

23-
Titles
23+
Headings
2424
------
2525

26-
The title of every guide uses `h1`; guide sections use `h2`; subsections `h3`; etc. However, the generated HTML output will have the heading tag starting from `<h2>`.
26+
The title of every guide uses an `h1` heading; guide sections use `h2` headings; subsections use `h3` headings; etc. Note that the generated HTML output will use heading tags starting with `<h2>`.
2727

2828
```
2929
Guide Title
@@ -35,14 +35,14 @@ Section
3535
### Sub Section
3636
```
3737

38-
Capitalize all words except for internal articles, prepositions, conjunctions, and forms of the verb to be:
38+
When writing headings, capitalize all words except for prepositions, conjunctions, internal articles, and forms of the verb "to be":
3939

4040
```
4141
#### Middleware Stack is an Array
4242
#### When are Objects Saved?
4343
```
4444

45-
Use the same typography as in regular text:
45+
Use the same inline formatting as regular text:
4646

4747
```
4848
##### The `:content_type` Option
@@ -51,25 +51,23 @@ Use the same typography as in regular text:
5151
API Documentation Guidelines
5252
----------------------------
5353

54-
The guides and the API should be coherent and consistent where appropriate. Please have a look at these particular sections of the [API Documentation Guidelines](api_documentation_guidelines.html):
54+
The guides and the API should be coherent and consistent where appropriate. In particular, these sections of the [API Documentation Guidelines](api_documentation_guidelines.html) also apply to the guides:
5555

5656
* [Wording](api_documentation_guidelines.html#wording)
5757
* [Example Code](api_documentation_guidelines.html#example-code)
58-
* [Filenames](api_documentation_guidelines.html#filenames)
58+
* [Filenames](api_documentation_guidelines.html#file-names)
5959
* [Fonts](api_documentation_guidelines.html#fonts)
6060

61-
Those guidelines apply also to guides.
62-
6361
HTML Guides
6462
-----------
6563

6664
Before generating the guides, make sure that you have the latest version of Bundler installed on your system. As of this writing, you must install Bundler 1.3.5 on your device.
6765

68-
To install the latest version of Bundler, simply run the `gem install bundler` command
66+
To install the latest version of Bundler, run `gem install bundler`.
6967

7068
### Generation
7169

72-
To generate all the guides, just `cd` into the `guides` directory, run `bundle install` and execute:
70+
To generate all the guides, just `cd` into the `guides` directory, run `bundle install`, and execute:
7371

7472
```
7573
bundle exec rake guides:generate

source/testing.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,17 +1014,9 @@ Testing helpers
10141014

10151015
In order to test helpers, all you need to do is check that the output of the
10161016
helper method matches what you'd expect. Tests related to the helpers are
1017-
located under the `test/helpers` directory. Rails provides a generator which
1018-
generates both the helper and the test file:
1017+
located under the `test/helpers` directory.
10191018

1020-
```bash
1021-
$ bin/rails generate helper User
1022-
create app/helpers/user_helper.rb
1023-
invoke test_unit
1024-
create test/helpers/user_helper_test.rb
1025-
```
1026-
1027-
The generated test file contains the following code:
1019+
A helper test looks like so:
10281020

10291021
```ruby
10301022
require 'test_helper'
@@ -1057,7 +1049,6 @@ The built-in `minitest` based testing is not the only way to test Rails applicat
10571049

10581050
* [NullDB](http://avdi.org/projects/nulldb/), a way to speed up testing by avoiding database use.
10591051
* [Factory Girl](https://github.com/thoughtbot/factory_girl/tree/master), a replacement for fixtures.
1060-
* [Machinist](https://github.com/notahat/machinist/tree/master), another replacement for fixtures.
10611052
* [Fixture Builder](https://github.com/rdy/fixture_builder), a tool that compiles Ruby factories into fixtures before a test run.
10621053
* [MiniTest::Spec Rails](https://github.com/metaskills/minitest-spec-rails), use the MiniTest::Spec DSL within your rails tests.
10631054
* [Shoulda](http://www.thoughtbot.com/projects/shoulda), an extension to `test/unit` with additional helpers, macros, and assertions.

source/upgrading_ruby_on_rails.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,43 @@ NOTE: This section is a work in progress.
5454

5555
### Serialized attributes
5656

57-
When assigning `nil` to a serialized attribute, it will be saved to the database
57+
When using a custom coder (e.g. `serialize :metadata, JSON`),
58+
assigning `nil` to a serialized attribute will save it to the database
5859
as `NULL` instead of passing the `nil` value through the coder (e.g. `"null"`
5960
when using the `JSON` coder).
6061

62+
### `after_bundle` in Rails templates
63+
64+
If you have a Rails template that adds all the files in version control, it
65+
fails to add the generated binstubs because it gets executed before Bundler:
66+
67+
```ruby
68+
# template.rb
69+
generate(:scaffold, "person name:string")
70+
route "root to: 'people#index'"
71+
rake("db:migrate")
72+
73+
git :init
74+
git add: "."
75+
git commit: %Q{ -m 'Initial commit' }
76+
```
77+
78+
You can now wrap the `git` calls in an `after_bundle` block. It will be run
79+
after the binstubs have been generated.
80+
81+
```ruby
82+
# template.rb
83+
generate(:scaffold, "person name:string")
84+
route "root to: 'people#index'"
85+
rake("db:migrate")
86+
87+
after_bundle do
88+
git :init
89+
git add: "."
90+
git commit: %Q{ -m 'Initial commit' }
91+
end
92+
```
93+
6194
Upgrading from Rails 4.0 to Rails 4.1
6295
-------------------------------------
6396

@@ -592,6 +625,9 @@ Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must rep
592625

593626
* Rails 4.0 has changed `serialized_attributes` and `attr_readonly` to class methods only. You shouldn't use instance methods since it's now deprecated. You should change them to use class methods, e.g. `self.serialized_attributes` to `self.class.serialized_attributes`.
594627

628+
* When using the default coder, assigning `nil` to a serialized attribute will save it
629+
to the database as `NULL` instead of passing the `nil` value through YAML (`"--- \n...\n"`).
630+
595631
* Rails 4.0 has removed `attr_accessible` and `attr_protected` feature in favor of Strong Parameters. You can use the [Protected Attributes gem](https://github.com/rails/protected_attributes) for a smooth upgrade path.
596632

597633
* If you are not using Protected Attributes, you can remove any options related to

0 commit comments

Comments
 (0)