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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -17
  3. data/guides/CHANGELOG.md +68 -34
  4. data/guides/assets/images/edge_badge.png +0 -0
  5. data/guides/assets/images/feature_tile.gif +0 -0
  6. data/guides/assets/images/footer_tile.gif +0 -0
  7. data/guides/assets/images/fxn.png +0 -0
  8. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  9. data/guides/assets/images/getting_started/challenge.png +0 -0
  10. data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
  11. data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  12. data/guides/assets/images/getting_started/form_with_errors.png +0 -0
  13. data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
  14. data/guides/assets/images/getting_started/new_article.png +0 -0
  15. data/guides/assets/images/getting_started/rails_welcome.png +0 -0
  16. data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
  17. data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
  18. data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
  19. data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
  20. data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
  21. data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
  22. data/guides/assets/images/header_tile.gif +0 -0
  23. data/guides/assets/images/icons/README +1 -1
  24. data/guides/assets/images/icons/callouts/11.png +0 -0
  25. data/guides/assets/images/icons/callouts/12.png +0 -0
  26. data/guides/assets/images/icons/callouts/13.png +0 -0
  27. data/guides/assets/images/icons/callouts/15.png +0 -0
  28. data/guides/assets/images/icons/caution.png +0 -0
  29. data/guides/assets/images/icons/example.png +0 -0
  30. data/guides/assets/images/radar.png +0 -0
  31. data/guides/assets/images/rails4_features.png +0 -0
  32. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  33. data/guides/assets/images/vijaydev.jpg +0 -0
  34. data/guides/assets/javascripts/guides.js +30 -34
  35. data/guides/assets/stylesheets/main.css +2 -1
  36. data/guides/assets/stylesheets/print.css +1 -1
  37. data/guides/bug_report_templates/action_controller_gem.rb +9 -4
  38. data/guides/bug_report_templates/action_controller_master.rb +4 -2
  39. data/guides/bug_report_templates/active_record_gem.rb +5 -2
  40. data/guides/bug_report_templates/active_record_master.rb +2 -1
  41. data/guides/bug_report_templates/generic_gem.rb +15 -0
  42. data/guides/bug_report_templates/generic_master.rb +26 -0
  43. data/guides/code/getting_started/Gemfile +21 -24
  44. data/guides/code/getting_started/Gemfile.lock +78 -73
  45. data/guides/code/getting_started/Rakefile +1 -1
  46. data/guides/code/getting_started/app/assets/javascripts/application.js +1 -2
  47. data/guides/code/getting_started/app/views/layouts/application.html.erb +2 -2
  48. data/guides/code/getting_started/config/environment.rb +1 -1
  49. data/guides/code/getting_started/config/environments/development.rb +2 -2
  50. data/guides/code/getting_started/config/environments/production.rb +3 -3
  51. data/guides/code/getting_started/config/environments/test.rb +2 -2
  52. data/guides/code/getting_started/config/initializers/secret_token.rb +1 -1
  53. data/guides/code/getting_started/config/initializers/session_store.rb +1 -1
  54. data/guides/code/getting_started/config/routes.rb +1 -1
  55. data/guides/code/getting_started/config.ru +1 -1
  56. data/guides/code/getting_started/public/404.html +2 -0
  57. data/guides/code/getting_started/public/422.html +2 -0
  58. data/guides/code/getting_started/public/500.html +2 -0
  59. data/guides/code/getting_started/test/test_helper.rb +0 -3
  60. data/guides/rails_guides/helpers.rb +3 -1
  61. data/guides/source/2_2_release_notes.md +2 -2
  62. data/guides/source/2_3_release_notes.md +8 -8
  63. data/guides/source/3_0_release_notes.md +2 -3
  64. data/guides/source/3_1_release_notes.md +2 -2
  65. data/guides/source/3_2_release_notes.md +12 -12
  66. data/guides/source/4_0_release_notes.md +79 -46
  67. data/guides/source/4_1_release_notes.md +731 -0
  68. data/guides/source/_welcome.html.erb +5 -2
  69. data/guides/source/action_controller_overview.md +189 -40
  70. data/guides/source/action_mailer_basics.md +27 -27
  71. data/guides/source/action_view_overview.md +131 -20
  72. data/guides/source/active_model_basics.md +6 -6
  73. data/guides/source/active_record_basics.md +15 -15
  74. data/guides/source/active_record_callbacks.md +18 -16
  75. data/guides/source/active_record_querying.md +93 -51
  76. data/guides/source/active_record_validations.md +26 -24
  77. data/guides/source/active_support_core_extensions.md +72 -118
  78. data/guides/source/active_support_instrumentation.md +13 -4
  79. data/guides/source/api_documentation_guidelines.md +104 -6
  80. data/guides/source/asset_pipeline.md +573 -244
  81. data/guides/source/association_basics.md +94 -22
  82. data/guides/source/caching_with_rails.md +15 -6
  83. data/guides/source/command_line.md +55 -46
  84. data/guides/source/configuring.md +248 -52
  85. data/guides/source/contributing_to_ruby_on_rails.md +18 -17
  86. data/guides/source/credits.html.erb +2 -2
  87. data/guides/source/debugging_rails_applications.md +39 -8
  88. data/guides/source/development_dependencies_install.md +91 -8
  89. data/guides/source/documents.yaml +4 -0
  90. data/guides/source/engines.md +678 -232
  91. data/guides/source/form_helpers.md +53 -35
  92. data/guides/source/generators.md +19 -15
  93. data/guides/source/getting_started.md +758 -497
  94. data/guides/source/i18n.md +64 -28
  95. data/guides/source/index.html.erb +1 -1
  96. data/guides/source/initialization.md +155 -58
  97. data/guides/source/kindle/toc.html.erb +1 -1
  98. data/guides/source/layout.html.erb +2 -2
  99. data/guides/source/layouts_and_rendering.md +59 -26
  100. data/guides/source/maintenance_policy.md +3 -3
  101. data/guides/source/migrations.md +101 -62
  102. data/guides/source/nested_model_forms.md +3 -3
  103. data/guides/source/plugins.md +34 -31
  104. data/guides/source/rails_application_templates.md +27 -8
  105. data/guides/source/rails_on_rack.md +41 -58
  106. data/guides/source/routing.md +115 -104
  107. data/guides/source/ruby_on_rails_guides_guidelines.md +2 -2
  108. data/guides/source/security.md +81 -36
  109. data/guides/source/testing.md +56 -79
  110. data/guides/source/upgrading_ruby_on_rails.md +531 -21
  111. data/guides/source/working_with_javascript_in_rails.md +19 -11
  112. metadata +51 -23
  113. data/guides/assets/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  114. data/guides/assets/images/getting_started/new_post.png +0 -0
  115. data/guides/assets/images/getting_started/post_with_comments.png +0 -0
  116. data/guides/assets/images/getting_started/show_action_for_posts.png +0 -0
  117. data/guides/assets/images/getting_started/template_is_missing_posts_new.png +0 -0
  118. data/guides/assets/images/getting_started/undefined_method_post_path.png +0 -0
  119. data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
  120. data/guides/assets/images/getting_started/unknown_action_new_for_posts.png +0 -0
  121. data/guides/assets/images/jaimeiniesta.jpg +0 -0
  122. data/guides/source/kindle/KINDLE.md +0 -26
@@ -40,7 +40,7 @@ Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wi
40
40
  <% end %>
41
41
 
42
42
  <%= author('Tore Darell', 'toretore') do %>
43
- Tore Darell is an independent developer based in Menton, France who specialises in cruft-free web applications using Ruby, Rails and unobtrusive JavaScript. His home on the internet is his blog <a href="http://tore.darell.no">Sneaky Abstractions</a>.
43
+ Tore Darell is an independent developer based in Menton, France who specialises in cruft-free web applications using Ruby, Rails and unobtrusive JavaScript. His home on the Internet is his blog <a href="http://tore.darell.no">Sneaky Abstractions</a>.
44
44
  <% end %>
45
45
 
46
46
  <%= author('Jeff Dean', 'zilkey') do %>
@@ -76,5 +76,5 @@ Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wi
76
76
  <% end %>
77
77
 
78
78
  <%= author('Akshay Surve', 'startupjockey', 'akshaysurve.jpg') do %>
79
- Akshay Surve is the Founder at <a href="http://www.deltax.com">DeltaX</a>, hackathon specialist, a midnight code junkie and ocassionally writes prose. You can connect with him on <a href="https://twitter.com/akshaysurve">Twitter</a>, <a href="http://www.linkedin.com/in/akshaysurve">Linkedin</a>, <a href="http://www.akshaysurve.com/">Personal Blog</a> or <a href="http://www.quora.com/Akshay-Surve">Quora</a>.
79
+ Akshay Surve is the Founder at <a href="http://www.deltax.com">DeltaX</a>, hackathon specialist, a midnight code junkie and occasionally writes prose. You can connect with him on <a href="https://twitter.com/akshaysurve">Twitter</a>, <a href="http://www.linkedin.com/in/akshaysurve">Linkedin</a>, <a href="http://www.akshaysurve.com/">Personal Blog</a> or <a href="http://www.quora.com/Akshay-Surve">Quora</a>.
80
80
  <% end %>
@@ -198,7 +198,7 @@ Adding extra logging like this makes it easy to search for unexpected or unusual
198
198
 
199
199
  ### Tagged Logging
200
200
 
201
- When running multi-user, multi-account applications, its often useful
201
+ When running multi-user, multi-account applications, it's often useful
202
202
  to be able to filter the logs using some custom rules. `TaggedLogging`
203
203
  in Active Support helps in doing exactly that by stamping log lines with subdomains, request ids, and anything else to aid debugging such applications.
204
204
 
@@ -209,6 +209,37 @@ logger.tagged("BCX", "Jason") { logger.info "Stuff" } # Logs "
209
209
  logger.tagged("BCX") { logger.tagged("Jason") { logger.info "Stuff" } } # Logs "[BCX] [Jason] Stuff"
210
210
  ```
211
211
 
212
+ ### Impact of Logs on Performance
213
+ Logging will always have a small impact on performance of your rails app,
214
+ particularly when logging to disk.However, there are a few subtleties:
215
+
216
+ Using the `:debug` level will have a greater performance penalty than `:fatal`,
217
+ as a far greater number of strings are being evaluated and written to the
218
+ log output (e.g. disk).
219
+
220
+ Another potential pitfall is that if you have many calls to `Logger` like this
221
+ in your code:
222
+
223
+ ```ruby
224
+ logger.debug "Person attributes hash: #{@person.attributes.inspect}"
225
+ ```
226
+
227
+ In the above example, There will be a performance impact even if the allowed
228
+ output level doesn't include debug. The reason is that Ruby has to evaluate
229
+ these strings, which includes instantiating the somewhat heavy `String` object
230
+ and interpolating the variables, and which takes time.
231
+ Therefore, it's recommended to pass blocks to the logger methods, as these are
232
+ only evaluated if the output level is the same or included in the allowed level
233
+ (i.e. lazy loading). The same code rewritten would be:
234
+
235
+ ```ruby
236
+ logger.debug {"Person attributes hash: #{@person.attributes.inspect}"}
237
+ ```
238
+
239
+ The contents of the block, and therefore the string interpolation, is only
240
+ evaluated if debug is enabled. This performance savings is only really
241
+ noticeable with large amounts of logging, but it's a good practice to employ.
242
+
212
243
  Debugging with the `debugger` gem
213
244
  ---------------------------------
214
245
 
@@ -248,12 +279,12 @@ Make sure you have started your web server with the option `--debugger`:
248
279
  ```bash
249
280
  $ rails server --debugger
250
281
  => Booting WEBrick
251
- => Rails 4.0.0 application starting on http://0.0.0.0:3000
282
+ => Rails 4.1.4 application starting on http://0.0.0.0:3000
252
283
  => Debugger enabled
253
284
  ...
254
285
  ```
255
286
 
256
- TIP: In development mode, you can dynamically `require \'debugger\'` instead of restarting the server, even if it was started without `--debugger`.
287
+ TIP: In development mode, you can dynamically `require 'debugger'` instead of restarting the server, even if it was started without `--debugger`.
257
288
 
258
289
  ### The Shell
259
290
 
@@ -301,7 +332,7 @@ This command shows you where you are in the code by printing 10 lines centered a
301
332
  7
302
333
  8 respond_to do |format|
303
334
  9 format.html # index.html.erb
304
- 10 format.json { render :json => @posts }
335
+ 10 format.json { render json: @posts }
305
336
  ```
306
337
 
307
338
  If you repeat the `list` command, this time using just `l`, the next ten lines of the file will be printed out.
@@ -337,7 +368,7 @@ On the other hand, to see the previous ten lines you should type `list-` (or `l-
337
368
  7
338
369
  8 respond_to do |format|
339
370
  9 format.html # index.html.erb
340
- 10 format.json { render :json => @posts }
371
+ 10 format.json { render json: @posts }
341
372
  ```
342
373
 
343
374
  This way you can move inside the file, being able to see the code above and over the line you added the `debugger`.
@@ -355,7 +386,7 @@ Finally, to see where you are in the code again you can type `list=`
355
386
  7
356
387
  8 respond_to do |format|
357
388
  9 format.html # index.html.erb
358
- 10 format.json { render :json => @posts }
389
+ 10 format.json { render json: @posts }
359
390
  ```
360
391
 
361
392
  ### The Context
@@ -504,7 +535,7 @@ TIP: You can use the debugger while using `rails console`. Just remember to `req
504
535
 
505
536
  ```
506
537
  $ rails console
507
- Loading development environment (Rails 4.0.0)
538
+ Loading development environment (Rails 4.1.4)
508
539
  >> require "debugger"
509
540
  => []
510
541
  >> author = Author.first
@@ -648,7 +679,7 @@ In this section, you will learn how to find and fix such leaks by using tool suc
648
679
 
649
680
  [Valgrind](http://valgrind.org/) is a Linux-only application for detecting C-based memory leaks and race conditions.
650
681
 
651
- There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. For example, a C extension in the interpreter calls `malloc()` but is doesn't properly call `free()`, this memory won't be available until the app terminates.
682
+ There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. For example, if a C extension in the interpreter calls `malloc()` but doesn't properly call `free()`, this memory won't be available until the app terminates.
652
683
 
653
684
  For further information on how to install Valgrind and use with Ruby, refer to [Valgrind and Ruby](http://blog.evanweaver.com/articles/2008/02/05/valgrind-and-ruby/) by Evan Weaver.
654
685
 
@@ -5,6 +5,10 @@ This guide covers how to setup an environment for Ruby on Rails core development
5
5
 
6
6
  After reading this guide, you will know:
7
7
 
8
+ * How to set up your machine for Rails development
9
+ * How to run specific groups of unit tests from the Rails test suite
10
+ * How the ActiveRecord portion of the Rails test suite operates
11
+
8
12
  --------------------------------------------------------------------------------
9
13
 
10
14
  The Easy Way
@@ -53,9 +57,24 @@ If you are on Fedora or CentOS, you can run
53
57
  $ sudo yum install libxml2 libxml2-devel libxslt libxslt-devel
54
58
  ```
55
59
 
56
- If you have any problems with these libraries, you should install them manually compiling the source code. Just follow the instructions at the [Red Hat/CentOS section of the Nokogiri tutorials](http://nokogiri.org/tutorials/installing_nokogiri.html#red_hat__centos) .
60
+ If you are running Arch Linux, you're done with:
61
+
62
+ ```bash
63
+ $ sudo pacman -S libxml2 libxslt
64
+ ```
65
+
66
+ On FreeBSD, you just have to run:
67
+
68
+ ```bash
69
+ # pkg_add -r libxml2 libxslt
70
+ ```
71
+
72
+ Alternatively, you can install the `textproc/libxml2` and `textproc/libxslt`
73
+ ports.
57
74
 
58
- Also, SQLite3 and its development files for the `sqlite3-ruby` gem in Ubuntu you're done with just
75
+ If you have any problems with these libraries, you can install them manually by compiling the source code. Just follow the instructions at the [Red Hat/CentOS section of the Nokogiri tutorials](http://nokogiri.org/tutorials/installing_nokogiri.html#red_hat__centos) .
76
+
77
+ Also, SQLite3 and its development files for the `sqlite3-ruby` gem - in Ubuntu you're done with just
59
78
 
60
79
  ```bash
61
80
  $ sudo apt-get install sqlite3 libsqlite3-dev
@@ -67,6 +86,20 @@ And if you are on Fedora or CentOS, you're done with
67
86
  $ sudo yum install sqlite3 sqlite3-devel
68
87
  ```
69
88
 
89
+ If you are on Arch Linux, you will need to run:
90
+
91
+ ```bash
92
+ $ sudo pacman -S sqlite
93
+ ```
94
+
95
+ For FreeBSD users, you're done with:
96
+
97
+ ```bash
98
+ # pkg_add -r sqlite3
99
+ ```
100
+
101
+ Or compile the `databases/sqlite3` port.
102
+
70
103
  Get a recent version of [Bundler](http://gembundler.com/)
71
104
 
72
105
  ```bash
@@ -80,7 +113,29 @@ and run:
80
113
  $ bundle install --without db
81
114
  ```
82
115
 
83
- This command will install all dependencies except the MySQL and PostgreSQL Ruby drivers. We will come back to these soon. With dependencies installed, you can run the test suite with:
116
+ This command will install all dependencies except the MySQL and PostgreSQL Ruby drivers. We will come back to these soon.
117
+
118
+ NOTE: If you would like to run the tests that use memcached, you need to ensure that you have it installed and running.
119
+
120
+ You can use homebrew to install memcached on OSX:
121
+
122
+ ```bash
123
+ $ brew install memcached
124
+ ```
125
+
126
+ On Ubuntu you can install it with apt-get:
127
+
128
+ ```bash
129
+ $ sudo apt-get install memcached
130
+ ```
131
+
132
+ Or use yum on Fedora or CentOS:
133
+
134
+ ```bash
135
+ $ sudo yum install memcached
136
+ ```
137
+
138
+ With the dependencies now installed, you can run the test suite with:
84
139
 
85
140
  ```bash
86
141
  $ bundle exec rake test
@@ -93,20 +148,27 @@ $ cd actionpack
93
148
  $ bundle exec rake test
94
149
  ```
95
150
 
96
- If you want to run the tests located in a specific directory use the `TEST_DIR` environment variable. For example, this will run the tests of the `railties/test/generators` directory only:
151
+ If you want to run the tests located in a specific directory use the `TEST_DIR` environment variable. For example, this will run the tests in the `railties/test/generators` directory only:
97
152
 
98
153
  ```bash
99
154
  $ cd railties
100
155
  $ TEST_DIR=generators bundle exec rake test
101
156
  ```
102
157
 
103
- You can run any single test separately too:
158
+ You can run the tests for a particular file by using:
104
159
 
105
160
  ```bash
106
161
  $ cd actionpack
107
162
  $ bundle exec ruby -Itest test/template/form_helper_test.rb
108
163
  ```
109
164
 
165
+ Or, you can run a single test in a particular file:
166
+
167
+ ```bash
168
+ $ cd actionpack
169
+ $ bundle exec ruby -Itest path/to/test.rb -n test_name
170
+ ```
171
+
110
172
  ### Active Record Setup
111
173
 
112
174
  The test suite of Active Record attempts to run four times: once for SQLite3, once for each of the two MySQL gems (`mysql` and `mysql2`), and once for PostgreSQL. We are going to see now how to set up the environment for them.
@@ -133,14 +195,33 @@ $ sudo yum install mysql-server mysql-devel
133
195
  $ sudo yum install postgresql-server postgresql-devel
134
196
  ```
135
197
 
136
- After that run:
198
+ If you are running Arch Linux, MySQL isn't supported anymore so you will need to
199
+ use MariaDB instead (see [this announcement](https://www.archlinux.org/news/mariadb-replaces-mysql-in-repositories/)):
200
+
201
+ ```bash
202
+ $ sudo pacman -S mariadb libmariadbclient mariadb-clients
203
+ $ sudo pacman -S postgresql postgresql-libs
204
+ ```
205
+
206
+ FreeBSD users will have to run the following:
207
+
208
+ ```bash
209
+ # pkg_add -r mysql56-client mysql56-server
210
+ # pkg_add -r postgresql92-client postgresql92-server
211
+ ```
212
+
213
+ Or install them through ports (they are located under the `databases` folder).
214
+ If you run into troubles during the installation of MySQL, please see
215
+ [the MySQL documentation](http://dev.mysql.com/doc/refman/5.1/en/freebsd-installation.html).
216
+
217
+ After that, run:
137
218
 
138
219
  ```bash
139
220
  $ rm .bundle/config
140
221
  $ bundle install
141
222
  ```
142
223
 
143
- We need first to delete `.bundle/config` because Bundler remembers in that file that we didn't want to install the "db" group (alternatively you can edit the file).
224
+ First, we need to delete `.bundle/config` because Bundler remembers in that file that we didn't want to install the "db" group (alternatively you can edit the file).
144
225
 
145
226
  In order to be able to run the test suite against MySQL you need to create a user named `rails` with privileges on the test databases:
146
227
 
@@ -152,6 +233,8 @@ mysql> GRANT ALL PRIVILEGES ON activerecord_unittest.*
152
233
  to 'rails'@'localhost';
153
234
  mysql> GRANT ALL PRIVILEGES ON activerecord_unittest2.*
154
235
  to 'rails'@'localhost';
236
+ mysql> GRANT ALL PRIVILEGES ON inexistent_activerecord_unittest.*
237
+ to 'rails'@'localhost';
155
238
  ```
156
239
 
157
240
  and create the test databases:
@@ -192,4 +275,4 @@ NOTE: Using the rake task to create the test databases ensures they have the cor
192
275
 
193
276
  NOTE: You'll see the following warning (or localized warning) during activating HStore extension in PostgreSQL 9.1.x or earlier: "WARNING: => is deprecated as an operator".
194
277
 
195
- If youre using another database, check the file `activerecord/test/config.yml` or `activerecord/test/config.example.yml` for default connection information. You can edit `activerecord/test/config.yml` to provide different credentials on your machine if you must, but obviously you should not push any such changes back to Rails.
278
+ If you're using another database, check the file `activerecord/test/config.yml` or `activerecord/test/config.example.yml` for default connection information. You can edit `activerecord/test/config.yml` to provide different credentials on your machine if you must, but obviously you should not push any such changes back to Rails.
@@ -163,6 +163,10 @@
163
163
  name: Upgrading Ruby on Rails
164
164
  url: upgrading_ruby_on_rails.html
165
165
  description: This guide helps in upgrading applications to latest Ruby on Rails versions.
166
+ -
167
+ name: Ruby on Rails 4.1 Release Notes
168
+ url: 4_1_release_notes.html
169
+ description: Release notes for Rails 4.1.
166
170
  -
167
171
  name: Ruby on Rails 4.0 Release Notes
168
172
  url: 4_0_release_notes.html