rails 4.1.14.2 → 4.2.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +12 -10
- data/guides/CHANGELOG.md +34 -37
- data/guides/Rakefile +21 -6
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/javascripts/guides.js +6 -0
- data/guides/assets/stylesheets/main.css +4 -1
- data/guides/bug_report_templates/action_controller_gem.rb +1 -1
- data/guides/bug_report_templates/action_controller_master.rb +1 -0
- data/guides/bug_report_templates/active_record_gem.rb +1 -1
- data/guides/bug_report_templates/generic_gem.rb +1 -1
- data/guides/rails_guides/helpers.rb +1 -1
- data/guides/rails_guides/levenshtein.rb +27 -21
- data/guides/rails_guides/markdown/renderer.rb +1 -1
- data/guides/rails_guides/markdown.rb +11 -7
- data/guides/rails_guides.rb +2 -2
- data/guides/source/2_2_release_notes.md +1 -1
- data/guides/source/2_3_release_notes.md +4 -4
- data/guides/source/3_0_release_notes.md +8 -8
- data/guides/source/3_1_release_notes.md +5 -2
- data/guides/source/3_2_release_notes.md +6 -3
- data/guides/source/4_0_release_notes.md +6 -3
- data/guides/source/4_1_release_notes.md +5 -6
- data/guides/source/4_2_release_notes.md +877 -0
- data/guides/source/_license.html.erb +1 -1
- data/guides/source/_welcome.html.erb +6 -8
- data/guides/source/action_controller_overview.md +25 -8
- data/guides/source/action_mailer_basics.md +97 -29
- data/guides/source/action_view_overview.md +142 -183
- data/guides/source/active_job_basics.md +339 -0
- data/guides/source/active_model_basics.md +371 -17
- data/guides/source/active_record_basics.md +25 -24
- data/guides/source/active_record_callbacks.md +12 -9
- data/guides/source/{migrations.md → active_record_migrations.md} +95 -220
- data/guides/source/active_record_postgresql.md +433 -0
- data/guides/source/active_record_querying.md +264 -268
- data/guides/source/active_record_validations.md +23 -13
- data/guides/source/active_support_core_extensions.md +114 -75
- data/guides/source/active_support_instrumentation.md +10 -18
- data/guides/source/api_documentation_guidelines.md +63 -17
- data/guides/source/asset_pipeline.md +258 -119
- data/guides/source/association_basics.md +96 -80
- data/guides/source/autoloading_and_reloading_constants.md +1311 -0
- data/guides/source/caching_with_rails.md +32 -7
- data/guides/source/command_line.md +52 -30
- data/guides/source/configuring.md +161 -33
- data/guides/source/contributing_to_ruby_on_rails.md +198 -114
- data/guides/source/credits.html.erb +2 -2
- data/guides/source/debugging_rails_applications.md +440 -286
- data/guides/source/development_dependencies_install.md +47 -36
- data/guides/source/documents.yaml +19 -7
- data/guides/source/engines.md +189 -189
- data/guides/source/form_helpers.md +79 -56
- data/guides/source/generators.md +24 -11
- data/guides/source/getting_started.md +359 -219
- data/guides/source/i18n.md +110 -66
- data/guides/source/index.html.erb +1 -0
- data/guides/source/initialization.md +109 -62
- data/guides/source/layout.html.erb +5 -11
- data/guides/source/layouts_and_rendering.md +26 -26
- data/guides/source/maintenance_policy.md +6 -3
- data/guides/source/nested_model_forms.md +7 -4
- data/guides/source/plugins.md +27 -27
- data/guides/source/rails_application_templates.md +21 -3
- data/guides/source/rails_on_rack.md +8 -5
- data/guides/source/routing.md +113 -73
- data/guides/source/ruby_on_rails_guides_guidelines.md +11 -12
- data/guides/source/security.md +39 -33
- data/guides/source/testing.md +199 -119
- data/guides/source/upgrading_ruby_on_rails.md +287 -29
- data/guides/source/working_with_javascript_in_rails.md +19 -17
- data/guides/w3c_validator.rb +2 -0
- metadata +40 -95
- data/guides/code/getting_started/Gemfile +0 -40
- data/guides/code/getting_started/Gemfile.lock +0 -125
- data/guides/code/getting_started/README.rdoc +0 -28
- data/guides/code/getting_started/Rakefile +0 -6
- data/guides/code/getting_started/app/assets/javascripts/application.js +0 -15
- data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/javascripts/welcome.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
- data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/welcome.css.scss +0 -3
- data/guides/code/getting_started/app/controllers/application_controller.rb +0 -5
- data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -23
- data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -53
- data/guides/code/getting_started/app/controllers/welcome_controller.rb +0 -4
- data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/welcome_helper.rb +0 -2
- data/guides/code/getting_started/app/models/comment.rb +0 -3
- data/guides/code/getting_started/app/models/post.rb +0 -7
- data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
- data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
- data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
- data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -27
- data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -5
- data/guides/code/getting_started/app/views/posts/index.html.erb +0 -21
- data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
- data/guides/code/getting_started/app/views/posts/show.html.erb +0 -18
- data/guides/code/getting_started/app/views/welcome/index.html.erb +0 -4
- data/guides/code/getting_started/bin/bundle +0 -4
- data/guides/code/getting_started/bin/rails +0 -4
- data/guides/code/getting_started/bin/rake +0 -4
- data/guides/code/getting_started/config/application.rb +0 -18
- data/guides/code/getting_started/config/boot.rb +0 -4
- data/guides/code/getting_started/config/database.yml +0 -25
- data/guides/code/getting_started/config/environment.rb +0 -5
- data/guides/code/getting_started/config/environments/development.rb +0 -30
- data/guides/code/getting_started/config/environments/production.rb +0 -80
- data/guides/code/getting_started/config/environments/test.rb +0 -36
- data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
- data/guides/code/getting_started/config/initializers/filter_parameter_logging.rb +0 -4
- data/guides/code/getting_started/config/initializers/inflections.rb +0 -16
- data/guides/code/getting_started/config/initializers/locale.rb +0 -9
- data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
- data/guides/code/getting_started/config/initializers/secret_token.rb +0 -12
- data/guides/code/getting_started/config/initializers/session_store.rb +0 -3
- data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
- data/guides/code/getting_started/config/locales/en.yml +0 -23
- data/guides/code/getting_started/config/routes.rb +0 -7
- data/guides/code/getting_started/config.ru +0 -4
- data/guides/code/getting_started/db/migrate/20130122042648_create_posts.rb +0 -10
- data/guides/code/getting_started/db/migrate/20130122045842_create_comments.rb +0 -11
- data/guides/code/getting_started/db/schema.rb +0 -33
- data/guides/code/getting_started/db/seeds.rb +0 -7
- data/guides/code/getting_started/public/404.html +0 -60
- data/guides/code/getting_started/public/422.html +0 -60
- data/guides/code/getting_started/public/500.html +0 -59
- data/guides/code/getting_started/public/favicon.ico +0 -0
- data/guides/code/getting_started/public/robots.txt +0 -5
- data/guides/code/getting_started/test/controllers/comments_controller_test.rb +0 -7
- data/guides/code/getting_started/test/controllers/posts_controller_test.rb +0 -7
- data/guides/code/getting_started/test/controllers/welcome_controller_test.rb +0 -9
- data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
- data/guides/code/getting_started/test/fixtures/posts.yml +0 -9
- data/guides/code/getting_started/test/helpers/comments_helper_test.rb +0 -4
- data/guides/code/getting_started/test/helpers/posts_helper_test.rb +0 -4
- data/guides/code/getting_started/test/helpers/welcome_helper_test.rb +0 -4
- data/guides/code/getting_started/test/models/comment_test.rb +0 -7
- data/guides/code/getting_started/test/models/post_test.rb +0 -7
- data/guides/code/getting_started/test/test_helper.rb +0 -12
@@ -13,7 +13,19 @@ After reading this guide, you will know:
|
|
13
13
|
RDoc
|
14
14
|
----
|
15
15
|
|
16
|
-
The Rails API documentation
|
16
|
+
The [Rails API documentation](http://api.rubyonrails.org) is generated with
|
17
|
+
[RDoc](http://docs.seattlerb.org/rdoc/).
|
18
|
+
|
19
|
+
```bash
|
20
|
+
bundle exec rake rdoc
|
21
|
+
```
|
22
|
+
|
23
|
+
Resulting HTML files can be found in the ./doc/rdoc directory.
|
24
|
+
|
25
|
+
Please consult the RDoc documentation for help with the
|
26
|
+
[markup](http://docs.seattlerb.org/rdoc/RDoc/Markup.html),
|
27
|
+
and also take into account these [additional
|
28
|
+
directives](http://docs.seattlerb.org/rdoc/RDoc/Parser/Ruby.html).
|
17
29
|
|
18
30
|
Wording
|
19
31
|
-------
|
@@ -67,7 +79,7 @@ used. Instead of:
|
|
67
79
|
English
|
68
80
|
-------
|
69
81
|
|
70
|
-
Please use American English (
|
82
|
+
Please use American English (*color*, *center*, *modularize*, etc). See [a list of American and British English spelling differences here](http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences).
|
71
83
|
|
72
84
|
Example Code
|
73
85
|
------------
|
@@ -99,7 +111,7 @@ On the other hand, big chunks of structured documentation may have a separate "E
|
|
99
111
|
The results of expressions follow them and are introduced by "# => ", vertically aligned:
|
100
112
|
|
101
113
|
```ruby
|
102
|
-
# For checking if
|
114
|
+
# For checking if an integer is even or odd.
|
103
115
|
#
|
104
116
|
# 1.even? # => false
|
105
117
|
# 1.odd? # => true
|
@@ -110,14 +122,14 @@ The results of expressions follow them and are introduced by "# => ", vertically
|
|
110
122
|
If a line is too long, the comment may be placed on the next line:
|
111
123
|
|
112
124
|
```ruby
|
113
|
-
# label(:
|
114
|
-
# # => <label for="
|
125
|
+
# label(:article, :title)
|
126
|
+
# # => <label for="article_title">Title</label>
|
115
127
|
#
|
116
|
-
# label(:
|
117
|
-
# # => <label for="
|
128
|
+
# label(:article, :title, "A short title")
|
129
|
+
# # => <label for="article_title">A short title</label>
|
118
130
|
#
|
119
|
-
# label(:
|
120
|
-
# # => <label for="
|
131
|
+
# label(:article, :title, "A short title", class: "title_label")
|
132
|
+
# # => <label for="article_title" class="title_label">A short title</label>
|
121
133
|
```
|
122
134
|
|
123
135
|
Avoid using any printing methods like `puts` or `p` for that purpose.
|
@@ -175,8 +187,8 @@ end
|
|
175
187
|
The API is careful not to commit to any particular value, the method has
|
176
188
|
predicate semantics, that's enough.
|
177
189
|
|
178
|
-
|
179
|
-
|
190
|
+
File Names
|
191
|
+
----------
|
180
192
|
|
181
193
|
As a rule of thumb, use filenames relative to the application root:
|
182
194
|
|
@@ -215,6 +227,13 @@ ordinary method names, symbols, paths (with forward slashes), etc. Please use
|
|
215
227
|
`<tt>...</tt>` for everything else, notably class or module names with a
|
216
228
|
namespace as in `<tt>ActiveRecord::Base</tt>`.
|
217
229
|
|
230
|
+
You can quickly test the RDoc output with the following command:
|
231
|
+
|
232
|
+
```
|
233
|
+
$ echo "+:to_param+" | rdoc --pipe
|
234
|
+
#=> <p><code>:to_param</code></p>
|
235
|
+
```
|
236
|
+
|
218
237
|
### Regular Font
|
219
238
|
|
220
239
|
When "true" and "false" are English words rather than Ruby keywords use a regular font:
|
@@ -283,7 +302,7 @@ self.class_eval %{
|
|
283
302
|
Method Visibility
|
284
303
|
-----------------
|
285
304
|
|
286
|
-
When writing documentation for Rails, it's important to understand the difference between public
|
305
|
+
When writing documentation for Rails, it's important to understand the difference between public user-facing API vs internal API.
|
287
306
|
|
288
307
|
Rails, like most libraries, uses the private keyword from Ruby for defining internal API. However, public API follows a slightly different convention. Instead of assuming all public methods are designed for user consumption, Rails uses the `:nodoc:` directive to annotate these kinds of methods as internal API.
|
289
308
|
|
@@ -299,17 +318,44 @@ module ActiveRecord::Core::ClassMethods
|
|
299
318
|
end
|
300
319
|
```
|
301
320
|
|
302
|
-
If you thought, "this method looks like a public class method for `ActiveRecord::Core`", you were right. But actually the Rails team doesn't want users to rely on this method. So they mark it as `:nodoc:` and it's removed from public documentation. The reasoning behind this is to allow the team to change these methods according to their internal needs across releases as they see fit. The name of this method could change, or the return value, or this entire class may disappear; there's no guarantee and so you shouldn't depend on this API in your
|
321
|
+
If you thought, "this method looks like a public class method for `ActiveRecord::Core`", you were right. But actually the Rails team doesn't want users to rely on this method. So they mark it as `:nodoc:` and it's removed from public documentation. The reasoning behind this is to allow the team to change these methods according to their internal needs across releases as they see fit. The name of this method could change, or the return value, or this entire class may disappear; there's no guarantee and so you shouldn't depend on this API in your plugins or applications. Otherwise, you risk your app or gem breaking when you upgrade to a newer release of Rails.
|
303
322
|
|
304
|
-
As a contributor, it's important to think about whether this API is meant for end-user consumption. The Rails team is committed to not making any breaking changes to public API across releases without going through a full deprecation cycle
|
323
|
+
As a contributor, it's important to think about whether this API is meant for end-user consumption. The Rails team is committed to not making any breaking changes to public API across releases without going through a full deprecation cycle. It's recommended that you `:nodoc:` any of your internal methods/classes unless they're already private (meaning visibility), in which case it's internal by default. Once the API stabilizes the visibility can change, but changing public API is much harder due to backwards compatibility.
|
305
324
|
|
306
325
|
A class or module is marked with `:nodoc:` to indicate that all methods are internal API and should never be used directly.
|
307
326
|
|
308
|
-
If you come across an existing `:nodoc:` you should tread lightly. Consider asking someone from the core team or author of the code before removing it. This should almost always happen through a
|
327
|
+
If you come across an existing `:nodoc:` you should tread lightly. Consider asking someone from the core team or author of the code before removing it. This should almost always happen through a pull request instead of the docrails project.
|
309
328
|
|
310
329
|
A `:nodoc:` should never be added simply because a method or class is missing documentation. There may be an instance where an internal public method wasn't given a `:nodoc:` by mistake, for example when switching a method from private to public visibility. When this happens it should be discussed over a PR on a case-by-case basis and never committed directly to docrails.
|
311
330
|
|
312
|
-
To summarize, the Rails team uses `:nodoc:` to mark publicly visible methods and classes for internal use; changes to the visibility of API should be considered carefully and discussed over a
|
331
|
+
To summarize, the Rails team uses `:nodoc:` to mark publicly visible methods and classes for internal use; changes to the visibility of API should be considered carefully and discussed over a pull request first.
|
332
|
+
|
333
|
+
Regarding the Rails Stack
|
334
|
+
-------------------------
|
335
|
+
|
336
|
+
When documenting parts of Rails API, it's important to remember all of the
|
337
|
+
pieces that go into the Rails stack.
|
338
|
+
|
339
|
+
This means that behavior may change depending on the scope or context of the
|
340
|
+
method or class you're trying to document.
|
341
|
+
|
342
|
+
In various places there is different behavior when you take the entire stack
|
343
|
+
into account, one such example is
|
344
|
+
`ActionView::Helpers::AssetTagHelper#image_tag`:
|
345
|
+
|
346
|
+
```ruby
|
347
|
+
# image_tag("icon.png")
|
348
|
+
# # => <img alt="Icon" src="/assets/icon.png" />
|
349
|
+
```
|
350
|
+
|
351
|
+
Although the default behavior for `#image_tag` is to always return
|
352
|
+
`/images/icon.png`, we take into account the full Rails stack (including the
|
353
|
+
Asset Pipeline) we may see the result seen above.
|
354
|
+
|
355
|
+
We're only concerned with the behavior experienced when using the full default
|
356
|
+
Rails stack.
|
313
357
|
|
314
|
-
|
358
|
+
In this case, we want to document the behavior of the _framework_, and not just
|
359
|
+
this specific method.
|
315
360
|
|
361
|
+
If you have a question on how the Rails team handles certain API, don't hesitate to open a ticket or send a patch to the [issue tracker](https://github.com/rails/rails/issues).
|