rails 4.2.0 → 4.2.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 820f40537f6670c1bf36f61979047ac3b8173437
4
- data.tar.gz: 19860336f8213b3e83f09118a638d40a67b625bb
3
+ metadata.gz: fbf7ad3f9b760f4cdd5b30bc9dd9be23a6f7b7d4
4
+ data.tar.gz: ca13bb97946fa9f4a9b8517fdf4043e711c0659b
5
5
  SHA512:
6
- metadata.gz: 0d9aba1fdb1c9bcf61616777f57854700e8b58fde7a17eed6d39e5fed8e95751bccefc834a94aa2fd03e11f1aa4939dc7e7a48736d5e9dcda1b4ab28cc3ab094
7
- data.tar.gz: 0c778c7b93788d1f30764afe47f47a761c423f7d501b322c56a6ed0f66cd2147f85eda2c3a6bbb92283ed792868f36b6e6b3c1f860a81cd169c354d0823a3336
6
+ metadata.gz: aaed05f1486fa27d89acc7239cbf07c87621dd63ab788e0a714567d90740109213a3042dbfdbad2436b6d8d26c56a7199ee7f0177cb82e86179141021dbf8475
7
+ data.tar.gz: 872799adc56555f6417965d1b0ccf83e880dd5db9fd1e1baa26f6c9ecf0ea4bbd092e03a25d03f25f384df3aa9ad0cb94dc71b8064574ccb6a7cb40a5af83e10
@@ -1,3 +1,5 @@
1
+ ## Rails 4.2.0 (December 20, 2014) ##
2
+
1
3
  * New guide about constant autoloading and reloading.
2
4
 
3
5
  *Xavier Noria*
@@ -1,5 +1,5 @@
1
1
  # Activate the gem you are reporting the issue against.
2
- gem 'rails', '4.0.0'
2
+ gem 'rails', '4.2.0'
3
3
 
4
4
  require 'rails'
5
5
  require 'action_controller/railtie'
@@ -1,5 +1,5 @@
1
1
  # Activate the gem you are reporting the issue against.
2
- gem 'activerecord', '4.0.0'
2
+ gem 'activerecord', '4.2.0'
3
3
  require 'active_record'
4
4
  require 'minitest/autorun'
5
5
  require 'logger'
@@ -90,6 +90,9 @@ Post.find(2) # Subsequent calls reuse the cached prepared statement
90
90
  Post.find_by_title('first post')
91
91
  Post.find_by_title('second post')
92
92
 
93
+ Post.find_by(title: 'first post')
94
+ Post.find_by(title: 'second post')
95
+
93
96
  post.comments
94
97
  post.comments(true)
95
98
  ```
@@ -735,7 +735,7 @@ You can choose not to yield and build the response yourself, in which case the a
735
735
 
736
736
  While the most common way to use filters is by creating private methods and using *_action to add them, there are two other ways to do the same thing.
737
737
 
738
- The first is to use a block directly with the *_action methods. The block receives the controller as an argument, and the `require_login` filter from above could be rewritten to use a block:
738
+ The first is to use a block directly with the *\_action methods. The block receives the controller as an argument, and the `require_login` filter from above could be rewritten to use a block:
739
739
 
740
740
  ```ruby
741
741
  class ApplicationController < ActionController::Base
@@ -1164,67 +1164,10 @@ class ClientsController < ApplicationController
1164
1164
  end
1165
1165
  ```
1166
1166
 
1167
- WARNING: You shouldn't do `rescue_from Exception` or `rescue_from StandardError` unless you have a particular reason as it will cause serious side-effects (e.g. you won't be able to see exception details and tracebacks during development). If you would like to dynamically generate error pages, see [Custom errors page](#custom-errors-page).
1167
+ WARNING: You shouldn't do `rescue_from Exception` or `rescue_from StandardError` unless you have a particular reason as it will cause serious side-effects (e.g. you won't be able to see exception details and tracebacks during development).
1168
1168
 
1169
1169
  NOTE: Certain exceptions are only rescuable from the `ApplicationController` class, as they are raised before the controller gets initialized and the action gets executed. See Pratik Naik's [article](http://m.onkey.org/2008/7/20/rescue-from-dispatching) on the subject for more information.
1170
1170
 
1171
-
1172
- ### Custom errors page
1173
-
1174
- You can customize the layout of your error handling using controllers and views.
1175
- First define your app own routes to display the errors page.
1176
-
1177
- * `config/application.rb`
1178
-
1179
- ```ruby
1180
- config.exceptions_app = self.routes
1181
- ```
1182
-
1183
- * `config/routes.rb`
1184
-
1185
- ```ruby
1186
- match '/404', via: :all, to: 'errors#not_found'
1187
- match '/422', via: :all, to: 'errors#unprocessable_entity'
1188
- match '/500', via: :all, to: 'errors#server_error'
1189
- ```
1190
-
1191
- Create the controller and views.
1192
-
1193
- * `app/controllers/errors_controller.rb`
1194
-
1195
- ```ruby
1196
- class ErrorsController < ActionController::Base
1197
- layout 'error'
1198
-
1199
- def not_found
1200
- render status: :not_found
1201
- end
1202
-
1203
- def unprocessable_entity
1204
- render status: :unprocessable_entity
1205
- end
1206
-
1207
- def server_error
1208
- render status: :server_error
1209
- end
1210
- end
1211
- ```
1212
-
1213
- * `app/views`
1214
-
1215
- ```
1216
- errors/
1217
- not_found.html.erb
1218
- unprocessable_entity.html.erb
1219
- server_error.html.erb
1220
- layouts/
1221
- error.html.erb
1222
- ```
1223
-
1224
- Do not forget to set the correct status code on the controller as shown before.
1225
-
1226
- WARNING: You should avoid using the database or any complex operations because the user is already on the error page. Generating another error while on an error page could cause issues like presenting an empty page for the users.
1227
-
1228
1171
  Force HTTPS protocol
1229
1172
  --------------------
1230
1173
 
@@ -48,7 +48,7 @@ create test/mailers/previews/user_mailer_preview.rb
48
48
  ```ruby
49
49
  # app/mailers/application_mailer.rb
50
50
  class ApplicationMailer < ActionMailer::Base
51
- default "from@example.com"
51
+ default from: "from@example.com"
52
52
  layout 'mailer'
53
53
  end
54
54
 
@@ -743,7 +743,9 @@ Mailer framework. You can do this in an initializer file
743
743
  `config/initializers/sandbox_email_interceptor.rb`
744
744
 
745
745
  ```ruby
746
- ActionMailer::Base.register_interceptor(SandboxEmailInterceptor) if Rails.env.staging?
746
+ if Rails.env.staging?
747
+ ActionMailer::Base.register_interceptor(SandboxEmailInterceptor)
748
+ end
747
749
  ```
748
750
 
749
751
  NOTE: The example above uses a custom environment called "staging" for a
@@ -1977,8 +1977,8 @@ While Rails uses intelligent defaults that will work well in most situations, th
1977
1977
 
1978
1978
  ```ruby
1979
1979
  class Parts < ActiveRecord::Base
1980
- has_and_belongs_to_many :assemblies, autosave: true,
1981
- readonly: true
1980
+ has_and_belongs_to_many :assemblies, -> { readonly },
1981
+ autosave: true
1982
1982
  end
1983
1983
  ```
1984
1984
 
@@ -1990,7 +1990,6 @@ The `has_and_belongs_to_many` association supports these options:
1990
1990
  * `:foreign_key`
1991
1991
  * `:join_table`
1992
1992
  * `:validate`
1993
- * `:readonly`
1994
1993
 
1995
1994
  ##### `:association_foreign_key`
1996
1995
 
@@ -1,5 +1,5 @@
1
- Constant Autoloading and Reloading
2
- ==================================
1
+ Autoloading and Reloading Constants
2
+ ===================================
3
3
 
4
4
  This guide documents how constant autoloading and reloading works.
5
5
 
@@ -78,7 +78,8 @@ end
78
78
  ```
79
79
 
80
80
  The *nesting* at any given place is the collection of enclosing nested class and
81
- module objects outwards. For example, in the previous example, the nesting at
81
+ module objects outwards. The nesting at any given place can be inspected with
82
+ `Module.nesting`. For example, in the previous example, the nesting at
82
83
  (1) is
83
84
 
84
85
  ```ruby
@@ -111,6 +112,16 @@ certain nesting does not necessarily correlate with the namespaces at the spot.
111
112
  Even more, they are totally independent, take for instance
112
113
 
113
114
  ```ruby
115
+ module X
116
+ module Y
117
+ end
118
+ end
119
+
120
+ module A
121
+ module B
122
+ end
123
+ end
124
+
114
125
  module X::Y
115
126
  module A::B
116
127
  # (3)
@@ -138,9 +149,10 @@ executed, and popped after it.
138
149
 
139
150
  * A singleton class opened with `class << object` gets pushed, and popped later.
140
151
 
141
- * When any of the `*_eval` family of methods is called using a string argument,
152
+ * When `instance_eval` is called using a string argument,
142
153
  the singleton class of the receiver is pushed to the nesting of the eval'ed
143
- code.
154
+ code. When `class_eval` or `module_eval` is called using a string argument,
155
+ the receiver is pushed to the nesting of the eval'ed code.
144
156
 
145
157
  * The nesting at the top-level of code interpreted by `Kernel#load` is empty
146
158
  unless the `load` call receives a true value as second argument, in which case
@@ -151,8 +163,6 @@ the blocks that may be passed to `Class.new` and `Module.new` do not get the
151
163
  class or module being defined pushed to their nesting. That's one of the
152
164
  differences between defining classes and modules in one way or another.
153
165
 
154
- The nesting at any given place can be inspected with `Module.nesting`.
155
-
156
166
  ### Class and Module Definitions are Constant Assignments
157
167
 
158
168
  Let's suppose the following snippet creates a class (rather than reopening it):
@@ -186,8 +196,8 @@ Project.name # => "Project"
186
196
  ```
187
197
 
188
198
  Constant assignment has a special rule to make that happen: if the object
189
- being assigned is an anonymous class or module, Ruby sets its name to be the
190
- one the constant.
199
+ being assigned is an anonymous class or module, Ruby sets the object's name to
200
+ the name of the constant.
191
201
 
192
202
  INFO. From then on, what happens to the constant and the instance does not
193
203
  matter. For example, the constant could be deleted, the class object could be
@@ -221,7 +231,7 @@ assignment.
221
231
  Thus, when one informally says "the `String` class", that really means: the
222
232
  class object stored in the constant called "String" in the class object stored
223
233
  in the `Object` constant. `String` is otherwise an ordinary Ruby constant and
224
- everything related to constants applies to it, resolution algorithms, etc.
234
+ everything related to constants such as resolution algorithms applies to it.
225
235
 
226
236
  Likewise, in the controller
227
237
 
@@ -234,7 +244,7 @@ end
234
244
  ```
235
245
 
236
246
  `Post` is not syntax for a class. Rather, `Post` is a regular Ruby constant. If
237
- all is good, the constant evaluates to an object that responds to `all`.
247
+ all is good, the constant is evaluated to an object that responds to `all`.
238
248
 
239
249
  That is why we talk about *constant* autoloading, Rails has the ability to
240
250
  load constants on the fly.
@@ -256,7 +266,7 @@ module Colors
256
266
  end
257
267
  ```
258
268
 
259
- First, when the `module` keyword is processed the interpreter creates a new
269
+ First, when the `module` keyword is processed, the interpreter creates a new
260
270
  entry in the constant table of the class object stored in the `Object` constant.
261
271
  Said entry associates the name "Colors" to a newly created module object.
262
272
  Furthermore, the interpreter sets the name of the new module object to be the
@@ -270,7 +280,7 @@ In particular, `Colors::RED` is totally unrelated to any other `RED` constant
270
280
  that may live in any other class or module object. If there were any, they
271
281
  would have separate entries in their respective constant tables.
272
282
 
273
- Put special attention in the previous paragraphs to the distinction between
283
+ Pay special attention in the previous paragraphs to the distinction between
274
284
  class and module objects, constant names, and value objects associated to them
275
285
  in constant tables.
276
286
 
@@ -289,12 +299,14 @@ order. The ancestors of those elements are ignored.
289
299
 
290
300
  2. If not found, then the algorithm walks up the ancestor chain of the cref.
291
301
 
292
- 3. If not found, `const_missing` is invoked on the cref. The default
302
+ 3. If not found and the cref is a module, the constant is looked up in `Object`.
303
+
304
+ 4. If not found, `const_missing` is invoked on the cref. The default
293
305
  implementation of `const_missing` raises `NameError`, but it can be overridden.
294
306
 
295
307
  Rails autoloading **does not emulate this algorithm**, but its starting point is
296
308
  the name of the constant to be autoloaded, and the cref. See more in [Relative
297
- References](#relative-references).
309
+ References](#autoloading-algorithms-relative-references).
298
310
 
299
311
  #### Resolution Algorithm for Qualified Constants
300
312
 
@@ -312,7 +324,7 @@ relative: `::Billing::Invoice`. That would force `Billing` to be looked up
312
324
  only as a top-level constant.
313
325
 
314
326
  `Invoice` on the other hand is qualified by `Billing` and we are going to see
315
- its resolution next. Let's call *parent* to that qualifying class or module
327
+ its resolution next. Let's define *parent* to be that qualifying class or module
316
328
  object, that is, `Billing` in the example above. The algorithm for qualified
317
329
  constants goes like this:
318
330
 
@@ -328,7 +340,7 @@ checked.
328
340
 
329
341
  Rails autoloading **does not emulate this algorithm**, but its starting point is
330
342
  the name of the constant to be autoloaded, and the parent. See more in
331
- [Qualified References](#qualified-references).
343
+ [Qualified References](#autoloading-algorithms-qualified-references).
332
344
 
333
345
 
334
346
  Vocabulary
@@ -439,14 +451,14 @@ default it contains:
439
451
  `app/controllers`. They do not need to be the default ones, any custom
440
452
  directories like `app/workers` belong automatically to `autoload_paths`.
441
453
 
442
- * Any existing second level directories called `app/*/concerns` in the
454
+ * Second level directories `app/{controllers,models}/concerns` in the
443
455
  application and engines.
444
456
 
445
457
  * The directory `test/mailers/previews`.
446
458
 
447
459
  Also, this collection is configurable via `config.autoload_paths`. For example,
448
460
  `lib` was in the list years ago, but no longer is. An application can opt-in
449
- throwing this to `config/application.rb`:
461
+ by adding this to `config/application.rb`:
450
462
 
451
463
  ```ruby
452
464
  config.autoload_paths += "#{Rails.root}/lib"
@@ -683,12 +695,12 @@ creates an empty module and assigns it to the `Admin` constant on the fly.
683
695
  ### Generic Procedure
684
696
 
685
697
  Relative references are reported to be missing in the cref where they were hit,
686
- and qualified references are reported to be missing in their parent. (See
698
+ and qualified references are reported to be missing in their parent (see
687
699
  [Resolution Algorithm for Relative
688
700
  Constants](#resolution-algorithm-for-relative-constants) at the beginning of
689
701
  this guide for the definition of *cref*, and [Resolution Algorithm for Qualified
690
702
  Constants](#resolution-algorithm-for-qualified-constants) for the definition of
691
- *parent*.)
703
+ *parent*).
692
704
 
693
705
  The procedure to autoload constant `C` in an arbitrary situation is as follows:
694
706
 
@@ -866,8 +878,8 @@ end
866
878
  ```
867
879
 
868
880
  To resolve `User` Ruby checks `Admin` in the former case, but it does not in
869
- the latter because it does not belong to the nesting. (See [Nesting](#nesting)
870
- and [Resolution Algorithms](#resolution-algorithms).)
881
+ the latter because it does not belong to the nesting (see [Nesting](#nesting)
882
+ and [Resolution Algorithms](#resolution-algorithms)).
871
883
 
872
884
  Unfortunately Rails autoloading does not know the nesting in the spot where the
873
885
  constant was missing and so it is not able to act as Ruby would. In particular,
@@ -889,7 +901,7 @@ end
889
901
 
890
902
  ### Autoloading and STI
891
903
 
892
- Single Table Inheritance (STI) is a feature of Active Record that easies
904
+ Single Table Inheritance (STI) is a feature of Active Record that enables
893
905
  storing a hierarchy of models in one single table. The API of such models is
894
906
  aware of the hierarchy and encapsulates some common needs. For example, given
895
907
  these classes:
@@ -1171,7 +1183,8 @@ class Hotel
1171
1183
  end
1172
1184
  ```
1173
1185
 
1174
- the expression `Hotel::Image` is ambiguous, depends on the execution path.
1186
+ the expression `Hotel::Image` is ambiguous because it depends on the execution
1187
+ path.
1175
1188
 
1176
1189
  As [we saw before](#resolution-algorithm-for-qualified-constants), Ruby looks
1177
1190
  up the constant in `Hotel` and its ancestors. If `app/models/image.rb` has
@@ -1280,8 +1293,8 @@ c.user # surprisingly fine, User
1280
1293
  c.user # NameError: uninitialized constant C::User
1281
1294
  ```
1282
1295
 
1283
- because it detects a parent namespace already has the constant (see [Qualified
1284
- References](#qualified-references).)
1296
+ because it detects that a parent namespace already has the constant (see [Qualified
1297
+ References](#autoloading-algorithms-qualified-references)).
1285
1298
 
1286
1299
  As with pure Ruby, within the body of a direct descendant of `BasicObject` use
1287
1300
  always absolute constant paths:
@@ -197,7 +197,7 @@ The full set of methods that can be used in this block are as follows:
197
197
  Every Rails application comes with a standard set of middleware which it uses in this order in the development environment:
198
198
 
199
199
  * `ActionDispatch::SSL` forces every request to be under HTTPS protocol. Will be available if `config.force_ssl` is set to `true`. Options passed to this can be configured by using `config.ssl_options`.
200
- * `ActionDispatch::Static` is used to serve static assets. Disabled if `config.serve_static_assets` is `false`.
200
+ * `ActionDispatch::Static` is used to serve static assets. Disabled if `config.serve_static_files` is `false`.
201
201
  * `Rack::Lock` wraps the app in mutex so it can only be called by a single thread at a time. Only enabled when `config.cache_classes` is `false`.
202
202
  * `ActiveSupport::Cache::Strategy::LocalCache` serves as a basic memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.
203
203
  * `Rack::Runtime` sets an `X-Runtime` header, containing the time (in seconds) taken to execute the request.
@@ -361,6 +361,10 @@ A CHANGELOG entry should summarize what was changed and should end with author's
361
361
 
362
362
  Your name can be added directly after the last word if you don't provide any code examples or don't need multiple paragraphs. Otherwise, it's best to make as a new paragraph.
363
363
 
364
+ ### Updating the Gemfile.lock
365
+
366
+ Some changes requires the dependencies to be upgraded. In these cases make sure you run `bundle update` to get the right version of the dependency and commit the `Gemfile.lock` file within your changes.
367
+
364
368
  ### Sanity Check
365
369
 
366
370
  You should not be the only person who looks at the code before you submit it.
@@ -123,9 +123,9 @@
123
123
  url: initialization.html
124
124
  description: This guide explains the internals of the Rails initialization process as of Rails 4
125
125
  -
126
- name: Constant Autoloading and Reloading
127
- url: constant_autoloading_and_reloading.html
128
- description: This guide documents how constant autoloading and reloading work.
126
+ name: Autoloading and Reloading Constants
127
+ url: autoloading_and_reloading_constants.html
128
+ description: This guide documents how autoloading and reloading constants work.
129
129
  -
130
130
  name: Extending Rails
131
131
  documents:
@@ -191,6 +191,9 @@ following in the `blog` directory:
191
191
  $ bin/rails server
192
192
  ```
193
193
 
194
+ TIP: If you are using Windows, you have to pass the scripts under the `bin`
195
+ folder directly to the Ruby interpreter e.g. `ruby bin\rails server`.
196
+
194
197
  TIP: Compiling CoffeeScript and JavaScript asset compression requires you
195
198
  have a JavaScript runtime available on your system, in the absence
196
199
  of a runtime you will see an `execjs` error during asset compilation.
@@ -1266,8 +1269,8 @@ bottom of the template:
1266
1269
  ```html+erb
1267
1270
  ...
1268
1271
 
1269
- <%= link_to 'Back', articles_path %> |
1270
- <%= link_to 'Edit', edit_article_path(@article) %>
1272
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1273
+ <%= link_to 'Back', articles_path %>
1271
1274
  ```
1272
1275
 
1273
1276
  And here's how our app looks so far:
@@ -1539,6 +1542,7 @@ class CreateComments < ActiveRecord::Migration
1539
1542
 
1540
1543
  t.timestamps null: false
1541
1544
  end
1545
+ add_foreign_key :comments, :articles
1542
1546
  end
1543
1547
  end
1544
1548
  ```
@@ -1558,6 +1562,8 @@ run against the current database, so in this case you will just see:
1558
1562
  == CreateComments: migrating =================================================
1559
1563
  -- create_table(:comments)
1560
1564
  -> 0.0115s
1565
+ -- add_foreign_key(:comments, :articles)
1566
+ -> 0.0000s
1561
1567
  == CreateComments: migrated (0.0119s) ========================================
1562
1568
  ```
1563
1569
 
@@ -1673,8 +1679,8 @@ So first, we'll wire up the Article show template
1673
1679
  </p>
1674
1680
  <% end %>
1675
1681
 
1676
- <%= link_to 'Back', articles_path %> |
1677
- <%= link_to 'Edit', edit_article_path(@article) %>
1682
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1683
+ <%= link_to 'Back', articles_path %>
1678
1684
  ```
1679
1685
 
1680
1686
  This adds a form on the `Article` show page that creates a new comment by
@@ -1754,8 +1760,8 @@ add that to the `app/views/articles/show.html.erb`.
1754
1760
  </p>
1755
1761
  <% end %>
1756
1762
 
1757
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1758
- <%= link_to 'Back to Articles', articles_path %>
1763
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1764
+ <%= link_to 'Back', articles_path %>
1759
1765
  ```
1760
1766
 
1761
1767
  Now you can add articles and comments to your blog and have them show up in the
@@ -1820,8 +1826,8 @@ following:
1820
1826
  </p>
1821
1827
  <% end %>
1822
1828
 
1823
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1824
- <%= link_to 'Back to Articles', articles_path %>
1829
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1830
+ <%= link_to 'Back', articles_path %>
1825
1831
  ```
1826
1832
 
1827
1833
  This will now render the partial in `app/views/comments/_comment.html.erb` once
@@ -1870,8 +1876,8 @@ Then you make the `app/views/articles/show.html.erb` look like the following:
1870
1876
  <h2>Add a comment:</h2>
1871
1877
  <%= render 'comments/form' %>
1872
1878
 
1873
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1874
- <%= link_to 'Back to Articles', articles_path %>
1879
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1880
+ <%= link_to 'Back', articles_path %>
1875
1881
  ```
1876
1882
 
1877
1883
  The second render just defines the partial template we want to render,
@@ -807,7 +807,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co
807
807
 
808
808
  | validation | with option | message | interpolation |
809
809
  | ------------ | ------------------------- | ------------------------- | ------------- |
810
- | confirmation | - | :confirmation | - |
810
+ | confirmation | - | :confirmation | attribute |
811
811
  | acceptance | - | :accepted | - |
812
812
  | presence | - | :blank | - |
813
813
  | absence | - | :present | - |
@@ -827,6 +827,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co
827
827
  | numericality | :equal_to | :equal_to | count |
828
828
  | numericality | :less_than | :less_than | count |
829
829
  | numericality | :less_than_or_equal_to | :less_than_or_equal_to | count |
830
+ | numericality | :other_than | :other_than | count |
830
831
  | numericality | :only_integer | :not_an_integer | - |
831
832
  | numericality | :odd | :odd | - |
832
833
  | numericality | :even | :even | - |
@@ -221,7 +221,16 @@ Every test contains one or more assertions. Only when all the assertions are suc
221
221
 
222
222
  ### Maintaining the test database schema
223
223
 
224
- In order to run your tests, your test database will need to have the current structure. The test helper checks whether your test database has any pending migrations. If so, it will try to load your `db/schema.rb` or `db/structure.sql` into the test database. If migrations are still pending, an error will be raised.
224
+ In order to run your tests, your test database will need to have the current
225
+ structure. The test helper checks whether your test database has any pending
226
+ migrations. If so, it will try to load your `db/schema.rb` or `db/structure.sql`
227
+ into the test database. If migrations are still pending, an error will be
228
+ raised. Usually this indicates that your schema is not fully migrated. Running
229
+ the migrations against the development database (`bin/rake db:migrate`) will
230
+ bring the schema up to date.
231
+
232
+ NOTE: If existing migrations required modifications, the test database needs to
233
+ be rebuilt. This can be done by executing `bin/rake db:test:prepare`.
225
234
 
226
235
  ### Running Tests
227
236
 
@@ -1100,7 +1109,7 @@ within a model:
1100
1109
  ```ruby
1101
1110
  require 'test_helper'
1102
1111
 
1103
- class ProductTest < ActiveSupport::TestCase
1112
+ class ProductTest < ActiveJob::TestCase
1104
1113
  test 'billing job scheduling' do
1105
1114
  assert_enqueued_with(job: BillingJob) do
1106
1115
  product.charge(account)
@@ -248,6 +248,22 @@ class Notifier < ActionMailer::Base
248
248
  end
249
249
  ```
250
250
 
251
+ ### Foreign Key Support
252
+
253
+ The migration DSL has been expanded to support foreign key definitions. If
254
+ you've been using the Foreigner gem, you might want to consider removing it.
255
+ Note that the foreign key support of Rails is a subset of Foreigner. This means
256
+ that not every Foreigner definition can be fully replaced by it's Rails
257
+ migration DSL counterpart.
258
+
259
+ The migration procedure is as follows:
260
+
261
+ 1. remove `gem "foreigner"` from the Gemfile.
262
+ 2. run `bundle install`.
263
+ 3. run `bin/rake db:schema:dump`.
264
+ 4. make sure that `db/schema.rb` contains every foreign key definition with
265
+ the necessary options.
266
+
251
267
  Upgrading from Rails 4.0 to Rails 4.1
252
268
  -------------------------------------
253
269
 
@@ -766,7 +782,7 @@ file (in `config/application.rb`):
766
782
  ```ruby
767
783
  # Require the gems listed in Gemfile, including any gems
768
784
  # you've limited to :test, :development, or :production.
769
- Bundler.require(:default, Rails.env)
785
+ Bundler.require(*Rails.groups)
770
786
  ```
771
787
 
772
788
  ### vendor/plugins
@@ -1110,7 +1126,7 @@ You can help test performance with these additions to your test environment:
1110
1126
 
1111
1127
  ```ruby
1112
1128
  # Configure static asset server for tests with Cache-Control for performance
1113
- config.serve_static_assets = true
1129
+ config.serve_static_files = true
1114
1130
  config.static_cache_control = 'public, max-age=3600'
1115
1131
  ```
1116
1132
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,112 +16,112 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
19
+ version: 4.2.1.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0
26
+ version: 4.2.1.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.0
33
+ version: 4.2.1.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.0
40
+ version: 4.2.1.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: actionview
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 4.2.0
47
+ version: 4.2.1.rc1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 4.2.0
54
+ version: 4.2.1.rc1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activemodel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 4.2.0
61
+ version: 4.2.1.rc1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 4.2.0
68
+ version: 4.2.1.rc1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activerecord
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 4.2.0
75
+ version: 4.2.1.rc1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 4.2.0
82
+ version: 4.2.1.rc1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: actionmailer
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 4.2.0
89
+ version: 4.2.1.rc1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 4.2.0
96
+ version: 4.2.1.rc1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: activejob
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 4.2.0
103
+ version: 4.2.1.rc1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 4.2.0
110
+ version: 4.2.1.rc1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: railties
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 4.2.0
117
+ version: 4.2.1.rc1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 4.2.0
124
+ version: 4.2.1.rc1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -342,10 +342,10 @@ files:
342
342
  - guides/source/api_documentation_guidelines.md
343
343
  - guides/source/asset_pipeline.md
344
344
  - guides/source/association_basics.md
345
+ - guides/source/autoloading_and_reloading_constants.md
345
346
  - guides/source/caching_with_rails.md
346
347
  - guides/source/command_line.md
347
348
  - guides/source/configuring.md
348
- - guides/source/constant_autoloading_and_reloading.md
349
349
  - guides/source/contributing_to_ruby_on_rails.md
350
350
  - guides/source/credits.html.erb
351
351
  - guides/source/debugging_rails_applications.md
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
398
398
  version: 1.8.11
399
399
  requirements: []
400
400
  rubyforge_project:
401
- rubygems_version: 2.2.2
401
+ rubygems_version: 2.4.5
402
402
  signing_key:
403
403
  specification_version: 4
404
404
  summary: Full-stack web application framework.