rails 4.2.2 → 4.2.3.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: ef52e36c108b2251945011d3d6ed7277ad84beb1
4
- data.tar.gz: 597f594ee2f9752ef352897df743403d467cf578
3
+ metadata.gz: 67a1d4417457879880fd534070b56b3e5dc2598f
4
+ data.tar.gz: cc31571df03a85133f4aabea4e00d57edfe1fe7e
5
5
  SHA512:
6
- metadata.gz: 9314becd1f901e36fea4192179027d9b8f70b06f017cb25872099195091ecfb26a96c1b0f33c67696f0a6fa15c12103ea827572473a1feb1214820c140d745de
7
- data.tar.gz: 5493ae25c9e0bbbfb329b665ff88228b1cb85984d3395fcab56acea9d232da665d39f9e0c8f14c1773900dbe10d728248bd2d8f412c3f74ca41dadd1a06f0f81
6
+ metadata.gz: ecf9862d9e15221d2d6e1d727214a01f36d9a66188fec3d5ef24195c2a548cdf03c0bdc73196901dff23b375434e9ce729e247c1a4b57e7a49639559f0e73f14
7
+ data.tar.gz: 6f84e3d9163e5e70bcad6e45946aff7f665894d1dccb30c18d8302ebf399eccf4efc53cd87c6425f6cdeaf03a6fd0fa5bc1f36185161d6401bbd8e86aa68d3bf
@@ -1,13 +1,18 @@
1
- ## Rails 4.2.2 (June 16, 2014) ##
1
+ ## Rails 4.2.3 (June 22, 2015) ##
2
2
 
3
3
  * No Changes *
4
4
 
5
5
 
6
- ## Rails 4.2.1 (March 19, 2014) ##
6
+ ## Rails 4.2.2 (June 16, 2015) ##
7
7
 
8
8
  * No Changes *
9
9
 
10
10
 
11
+ ## Rails 4.2.1 (March 19, 2015) ##
12
+
13
+ * No changes.
14
+
15
+
11
16
  ## Rails 4.2.0 (December 20, 2014) ##
12
17
 
13
18
  * New guide about constant autoloading and reloading.
@@ -0,0 +1,15 @@
1
+ # Activate the gems you are reporting the issue against.
2
+ gem 'activesupport', '4.2.0'
3
+ require 'active_support'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'minitest/autorun'
6
+
7
+ # Ensure backward compatibility with Minitest 4
8
+ Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
9
+
10
+ class BugTest < Minitest::Test
11
+ def test_stuff
12
+ assert "zomg".present?
13
+ refute "".present?
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ unless File.exist?('Gemfile')
2
+ File.write('Gemfile', <<-GEMFILE)
3
+ source 'https://rubygems.org'
4
+ gem 'rails', github: 'rails/rails'
5
+ gem 'arel', github: 'rails/arel'
6
+ GEMFILE
7
+
8
+ system 'bundle'
9
+ end
10
+
11
+ require 'bundler'
12
+ Bundler.setup(:default)
13
+
14
+ require 'active_support'
15
+ require 'active_support/core_ext/object/blank'
16
+ require 'minitest/autorun'
17
+
18
+ # Ensure backward compatibility with Minitest 4
19
+ Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
20
+
21
+ class BugTest < Minitest::Test
22
+ def test_stuff
23
+ assert "zomg".present?
24
+ refute "".present?
25
+ end
26
+ end
@@ -7,11 +7,9 @@ module RailsGuides
7
7
  t = str2
8
8
  n = s.length
9
9
  m = t.length
10
- max = n/2
11
10
 
12
11
  return m if (0 == n)
13
12
  return n if (0 == m)
14
- return n if (n - m).abs > max
15
13
 
16
14
  d = (0..m).to_a
17
15
  x = nil
@@ -300,6 +300,30 @@ application is using any of these spellings, you will need to update them:
300
300
  assert_select('p', 'AT&amp;T') # => false
301
301
  ```
302
302
 
303
+ Furthermore substitutions have changed syntax.
304
+
305
+ Now you have to use a `:match` CSS-like selector:
306
+
307
+ ```ruby
308
+ assert_select ":match('id', ?)", 'comment_1'
309
+ ```
310
+
311
+ Additionally Regexp substitutions look different when the assertion fails.
312
+ Notice how `/hello/` here:
313
+
314
+ ```ruby
315
+ assert_select(":match('id', ?)", /hello/)
316
+ ```
317
+
318
+ becomes `"(?-mix:hello)"`:
319
+
320
+ ```
321
+ Expected at least 1 element matching "div:match('id', "(?-mix:hello)")", found 0..
322
+ Expected 0 to be >= 1.
323
+ ```
324
+
325
+ See the [Rails Dom Testing](https://github.com/rails/rails-dom-testing/tree/8798b9349fb9540ad8cb9a0ce6cb88d1384a210b) documentation for more on `assert_select`.
326
+
303
327
 
304
328
  Railties
305
329
  --------
@@ -507,6 +507,9 @@ url helper.
507
507
  <%= user_url(@user, host: 'example.com') %>
508
508
  ```
509
509
 
510
+ NOTE: non-`GET` links require [jQuery UJS](https://github.com/rails/jquery-ujs)
511
+ and won't work in mailer templates. They will result in normal `GET` requests.
512
+
510
513
  ### Sending Multipart Emails
511
514
 
512
515
  Action Mailer will automatically send multipart emails if you have different
@@ -670,7 +673,7 @@ files (environment.rb, production.rb, etc...)
670
673
  | Configuration | Description |
671
674
  |---------------|-------------|
672
675
  |`logger`|Generates information on the mailing run if available. Can be set to `nil` for no logging. Compatible with both Ruby's own `Logger` and `Log4r` loggers.|
673
- |`smtp_settings`|Allows detailed configuration for `:smtp` delivery method:<ul><li>`:address` - Allows you to use a remote mail server. Just change it from its default `"localhost"` setting.</li><li>`:port` - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li>`:domain` - If you need to specify a HELO domain, you can do it here.</li><li>`:user_name` - If your mail server requires authentication, set the username in this setting.</li><li>`:password` - If your mail server requires authentication, set the password in this setting.</li><li>`:authentication` - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of `:plain`, `:login`, `:cram_md5`.</li><li>`:enable_starttls_auto` - Set this to `false` if there is a problem with your server certificate that you cannot resolve.</li></ul>|
676
+ |`smtp_settings`|Allows detailed configuration for `:smtp` delivery method:<ul><li>`:address` - Allows you to use a remote mail server. Just change it from its default `"localhost"` setting.</li><li>`:port` - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li>`:domain` - If you need to specify a HELO domain, you can do it here.</li><li>`:user_name` - If your mail server requires authentication, set the username in this setting.</li><li>`:password` - If your mail server requires authentication, set the password in this setting.</li><li>`:authentication` - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of `:plain` (will send the password in the clear), `:login` (will send password Base64 encoded) or `:cram_md5` (combines a Challenge/Response mechanism to exchange information and a cryptographic Message Digest 5 algorithm to hash important information)</li><li>`:enable_starttls_auto` - Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to `true`.</li><li>`:openssl_verify_mode` - When using TLS, you can set how OpenSSL checks the certificate. This is really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name of an OpenSSL verify constant ('none', 'peer', 'client_once', 'fail_if_no_peer_cert') or directly the constant (`OpenSSL::SSL::VERIFY_NONE`, `OpenSSL::SSL::VERIFY_PEER`, ...).</li></ul>|
674
677
  |`sendmail_settings`|Allows you to override options for the `:sendmail` delivery method.<ul><li>`:location` - The location of the sendmail executable. Defaults to `/usr/sbin/sendmail`.</li><li>`:arguments` - The command line arguments to be passed to sendmail. Defaults to `-i -t`.</li></ul>|
675
678
  |`raise_delivery_errors`|Whether or not errors should be raised if the email fails to be delivered. This only works if the external email server is configured for immediate delivery.|
676
679
  |`delivery_method`|Defines a delivery method. Possible values are:<ul><li>`:smtp` (default), can be configured by using `config.action_mailer.smtp_settings`.</li><li>`:sendmail`, can be configured by using `config.action_mailer.sendmail_settings`.</li><li>`:file`: save emails to files; can be configured by using `config.action_mailer.file_settings`.</li><li>`:test`: save emails to `ActionMailer::Base.deliveries` array.</li></ul>See [API docs](http://api.rubyonrails.org/classes/ActionMailer/Base.html) for more info.|
@@ -435,39 +435,13 @@ config.action_controller.asset_host = "assets.example.com"
435
435
  image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
436
436
  ```
437
437
 
438
- #### register_javascript_expansion
439
-
440
- Register one or more JavaScript files to be included when symbol is passed to javascript_include_tag. This method is typically intended to be called from plugin initialization to register JavaScript files that the plugin installed in `vendor/assets/javascripts`.
441
-
442
- ```ruby
443
- ActionView::Helpers::AssetTagHelper.register_javascript_expansion monkey: ["head", "body", "tail"]
444
-
445
- javascript_include_tag :monkey # =>
446
- <script src="/assets/head.js"></script>
447
- <script src="/assets/body.js"></script>
448
- <script src="/assets/tail.js"></script>
449
- ```
450
-
451
- #### register_stylesheet_expansion
452
-
453
- Register one or more stylesheet files to be included when symbol is passed to `stylesheet_link_tag`. This method is typically intended to be called from plugin initialization to register stylesheet files that the plugin installed in `vendor/assets/stylesheets`.
454
-
455
- ```ruby
456
- ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion monkey: ["head", "body", "tail"]
457
-
458
- stylesheet_link_tag :monkey # =>
459
- <link href="/assets/head.css" media="screen" rel="stylesheet" />
460
- <link href="/assets/body.css" media="screen" rel="stylesheet" />
461
- <link href="/assets/tail.css" media="screen" rel="stylesheet" />
462
- ```
463
-
464
438
  #### auto_discovery_link_tag
465
439
 
466
440
  Returns a link tag that browsers and feed readers can use to auto-detect an RSS or Atom feed.
467
441
 
468
442
  ```ruby
469
- auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {title: "RSS Feed"}) # =>
470
- <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed" />
443
+ auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", { title: "RSS Feed" }) # =>
444
+ <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed.rss" />
471
445
  ```
472
446
 
473
447
  #### image_path
@@ -1420,22 +1394,6 @@ date_field_tag "dob"
1420
1394
 
1421
1395
  Provides functionality for working with JavaScript in your views.
1422
1396
 
1423
- #### button_to_function
1424
-
1425
- Returns a button that'll trigger a JavaScript function using the onclick handler. Examples:
1426
-
1427
- ```ruby
1428
- button_to_function "Greeting", "alert('Hello world!')"
1429
- button_to_function "Delete", "if (confirm('Really?')) do_delete()"
1430
- button_to_function "Details" do |page|
1431
- page[:details].visual_effect :toggle_slide
1432
- end
1433
- ```
1434
-
1435
- #### define_javascript_functions
1436
-
1437
- Includes the Action Pack JavaScript libraries inside a single `script` tag.
1438
-
1439
1397
  #### escape_javascript
1440
1398
 
1441
1399
  Escape carrier returns and single and double quotes for JavaScript segments.
@@ -1456,15 +1414,6 @@ alert('All is good')
1456
1414
  </script>
1457
1415
  ```
1458
1416
 
1459
- #### link_to_function
1460
-
1461
- Returns a link that will trigger a JavaScript function using the onclick handler and return false after the fact.
1462
-
1463
- ```ruby
1464
- link_to_function "Greeting", "alert('Hello world!')"
1465
- # => <a onclick="alert('Hello world!'); return false;" href="#">Greeting</a>
1466
- ```
1467
-
1468
1417
  ### NumberHelper
1469
1418
 
1470
1419
  Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
@@ -171,18 +171,18 @@ name that should be used:
171
171
 
172
172
  ```ruby
173
173
  class Product < ActiveRecord::Base
174
- self.table_name = "PRODUCT"
174
+ self.table_name = "my_products"
175
175
  end
176
176
  ```
177
177
 
178
178
  If you do so, you will have to define manually the class name that is hosting
179
- the fixtures (class_name.yml) using the `set_fixture_class` method in your test
179
+ the fixtures (my_products.yml) using the `set_fixture_class` method in your test
180
180
  definition:
181
181
 
182
182
  ```ruby
183
- class FunnyJoke < ActiveSupport::TestCase
184
- set_fixture_class funny_jokes: Joke
185
- fixtures :funny_jokes
183
+ class ProductTest < ActiveSupport::TestCase
184
+ set_fixture_class my_products: Product
185
+ fixtures :my_products
186
186
  ...
187
187
  end
188
188
  ```
@@ -876,7 +876,7 @@ For example:
876
876
  Item.transaction do
877
877
  i = Item.lock.first
878
878
  i.name = 'Jones'
879
- i.save
879
+ i.save!
880
880
  end
881
881
  ```
882
882
 
@@ -3043,53 +3043,6 @@ The method `Range#overlaps?` says whether any two given ranges have non-void int
3043
3043
 
3044
3044
  NOTE: Defined in `active_support/core_ext/range/overlaps.rb`.
3045
3045
 
3046
- Extensions to `Proc`
3047
- --------------------
3048
-
3049
- ### `bind`
3050
-
3051
- As you surely know Ruby has an `UnboundMethod` class whose instances are methods that belong to the limbo of methods without a self. The method `Module#instance_method` returns an unbound method for example:
3052
-
3053
- ```ruby
3054
- Hash.instance_method(:delete) # => #<UnboundMethod: Hash#delete>
3055
- ```
3056
-
3057
- An unbound method is not callable as is, you need to bind it first to an object with `bind`:
3058
-
3059
- ```ruby
3060
- clear = Hash.instance_method(:clear)
3061
- clear.bind({a: 1}).call # => {}
3062
- ```
3063
-
3064
- Active Support defines `Proc#bind` with an analogous purpose:
3065
-
3066
- ```ruby
3067
- Proc.new { size }.bind([]).call # => 0
3068
- ```
3069
-
3070
- As you see that's callable and bound to the argument, the return value is indeed a `Method`.
3071
-
3072
- NOTE: To do so `Proc#bind` actually creates a method under the hood. If you ever see a method with a weird name like `__bind_1256598120_237302` in a stack trace you know now where it comes from.
3073
-
3074
- Action Pack uses this trick in `rescue_from` for example, which accepts the name of a method and also a proc as callbacks for a given rescued exception. It has to call them in either case, so a bound method is returned by `handler_for_rescue`, thus simplifying the code in the caller:
3075
-
3076
- ```ruby
3077
- def handler_for_rescue(exception)
3078
- _, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler|
3079
- ...
3080
- end
3081
-
3082
- case rescuer
3083
- when Symbol
3084
- method(rescuer)
3085
- when Proc
3086
- rescuer.bind(self)
3087
- end
3088
- end
3089
- ```
3090
-
3091
- NOTE: Defined in `active_support/core_ext/proc.rb`.
3092
-
3093
3046
  Extensions to `Date`
3094
3047
  --------------------
3095
3048
 
@@ -789,41 +789,6 @@ location ~ ^/assets/ {
789
789
  }
790
790
  ```
791
791
 
792
- #### GZip Compression
793
-
794
- When files are precompiled, Sprockets also creates a
795
- [gzipped](http://en.wikipedia.org/wiki/Gzip) (.gz) version of your assets. Web
796
- servers are typically configured to use a moderate compression ratio as a
797
- compromise, but since precompilation happens once, Sprockets uses the maximum
798
- compression ratio, thus reducing the size of the data transfer to the minimum.
799
- On the other hand, web servers can be configured to serve compressed content
800
- directly from disk, rather than deflating non-compressed files themselves.
801
-
802
- NGINX is able to do this automatically enabling `gzip_static`:
803
-
804
- ```nginx
805
- location ~ ^/(assets)/ {
806
- root /path/to/public;
807
- gzip_static on; # to serve pre-gzipped version
808
- expires max;
809
- add_header Cache-Control public;
810
- }
811
- ```
812
-
813
- This directive is available if the core module that provides this feature was
814
- compiled with the web server. Ubuntu/Debian packages, even `nginx-light`, have
815
- the module compiled. Otherwise, you may need to perform a manual compilation:
816
-
817
- ```bash
818
- ./configure --with-http_gzip_static_module
819
- ```
820
-
821
- If you're compiling NGINX with Phusion Passenger you'll need to pass that option
822
- when prompted.
823
-
824
- A robust configuration for Apache is possible but tricky; please Google around.
825
- (Or help update this Guide if you have a good configuration example for Apache.)
826
-
827
792
  ### Local Precompilation
828
793
 
829
794
  There are several reasons why you might want to precompile your assets locally.
@@ -1417,7 +1417,13 @@ The `collection_singular_ids=` method makes the collection contain only the obje
1417
1417
 
1418
1418
  ##### `collection.clear`
1419
1419
 
1420
- The `collection.clear` method removes every object from the collection. This destroys the associated objects if they are associated with `dependent: :destroy`, deletes them directly from the database if `dependent: :delete_all`, and otherwise sets their foreign keys to `NULL`.
1420
+ The `collection.clear` method removes all objects from the collection according to the strategy specified by the `dependent` option. If no option is given, it follows the default strategy. The default strategy for `has_many :through` associations is `delete_all`, and for `has_many` associations is to set the foreign keys to `NULL`.
1421
+
1422
+ ```ruby
1423
+ @customer.orders.clear
1424
+ ```
1425
+
1426
+ WARNING: Objects will be delete if they're associated with `dependent: :destroy`, just like `dependent: :delete_all`.
1421
1427
 
1422
1428
  ##### `collection.empty?`
1423
1429
 
@@ -1456,7 +1462,9 @@ The `collection.where` method finds objects within the collection based on the c
1456
1462
 
1457
1463
  ##### `collection.exists?(...)`
1458
1464
 
1459
- The `collection.exists?` method checks whether an object meeting the supplied conditions exists in the collection. It uses the same syntax and options as `ActiveRecord::Base.exists?`.
1465
+ The `collection.exists?` method checks whether an object meeting the supplied
1466
+ conditions exists in the collection. It uses the same syntax and options as
1467
+ [`ActiveRecord::Base.exists?`](http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-exists-3F).
1460
1468
 
1461
1469
  ##### `collection.build(attributes = {}, ...)`
1462
1470
 
@@ -1949,7 +1957,9 @@ The `collection.where` method finds objects within the collection based on the c
1949
1957
 
1950
1958
  ##### `collection.exists?(...)`
1951
1959
 
1952
- The `collection.exists?` method checks whether an object meeting the supplied conditions exists in the collection. It uses the same syntax and options as `ActiveRecord::Base.exists?`.
1960
+ The `collection.exists?` method checks whether an object meeting the supplied
1961
+ conditions exists in the collection. It uses the same syntax and options as
1962
+ [`ActiveRecord::Base.exists?`](http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-exists-3F).
1953
1963
 
1954
1964
  ##### `collection.build(attributes = {})`
1955
1965
 
@@ -461,8 +461,9 @@ Also, this collection is configurable via `config.autoload_paths`. For example,
461
461
  by adding this to `config/application.rb`:
462
462
 
463
463
  ```ruby
464
- config.autoload_paths += "#{Rails.root}/lib"
464
+ config.autoload_paths << "#{Rails.root}/lib"
465
465
  ```
466
+ `config.autoload_paths` is accessible from environment-specific configuration files, but any changes made to it outside `config/application.rb` don't have an effect.
466
467
 
467
468
  The value of `autoload_paths` can be inspected. In a just generated application
468
469
  it is (edited):
@@ -589,7 +589,7 @@ the comments, however, is not quite right yet. If you were to create a comment
589
589
  right now, you would see this error:
590
590
 
591
591
  ```
592
- Missing partial blorgh/comments/comment with {:handlers=>[:erb, :builder],
592
+ Missing partial blorgh/comments/_comment with {:handlers=>[:erb, :builder],
593
593
  :formats=>[:html], :locale=>[:en, :en]}. Searched in: *
594
594
  "/Users/ryan/Sites/side_projects/blorgh/test/dummy/app/views" *
595
595
  "/Users/ryan/Sites/side_projects/blorgh/app/views"
@@ -598,7 +598,7 @@ Missing partial blorgh/comments/comment with {:handlers=>[:erb, :builder],
598
598
  The engine is unable to find the partial required for rendering the comments.
599
599
  Rails looks first in the application's (`test/dummy`) `app/views` directory and
600
600
  then in the engine's `app/views` directory. When it can't find it, it will throw
601
- this error. The engine knows to look for `blorgh/comments/comment` because the
601
+ this error. The engine knows to look for `blorgh/comments/_comment` because the
602
602
  model object it is receiving is from the `Blorgh::Comment` class.
603
603
 
604
604
  This partial will be responsible for rendering just the comment text, for now.
@@ -696,8 +696,8 @@ haven't been copied over already. The first run for this command will output
696
696
  something such as this:
697
697
 
698
698
  ```bash
699
- Copied migration [timestamp_1]_create_blorgh_articles.rb from blorgh
700
- Copied migration [timestamp_2]_create_blorgh_comments.rb from blorgh
699
+ Copied migration [timestamp_1]_create_blorgh_articles.blorgh.rb from blorgh
700
+ Copied migration [timestamp_2]_create_blorgh_comments.blorgh.rb from blorgh
701
701
  ```
702
702
 
703
703
  The first timestamp (`[timestamp_1]`) will be the current time, and the second
@@ -829,11 +829,9 @@ Notice that only _one_ migration was copied over here. This is because the first
829
829
  two migrations were copied over the first time this command was run.
830
830
 
831
831
  ```
832
- NOTE Migration [timestamp]_create_blorgh_articles.rb from blorgh has been
833
- skipped. Migration with the same name already exists. NOTE Migration
834
- [timestamp]_create_blorgh_comments.rb from blorgh has been skipped. Migration
835
- with the same name already exists. Copied migration
836
- [timestamp]_add_author_id_to_blorgh_articles.rb from blorgh
832
+ NOTE Migration [timestamp]_create_blorgh_articles.blorgh.rb from blorgh has been skipped. Migration with the same name already exists.
833
+ NOTE Migration [timestamp]_create_blorgh_comments.blorgh.rb from blorgh has been skipped. Migration with the same name already exists.
834
+ Copied migration [timestamp]_add_author_id_to_blorgh_articles.blorgh.rb from blorgh
837
835
  ```
838
836
 
839
837
  Run the migration using:
@@ -888,7 +886,9 @@ engine this would be done by changing
888
886
  `app/controllers/blorgh/application_controller.rb` to look like:
889
887
 
890
888
  ```ruby
891
- class Blorgh::ApplicationController < ApplicationController
889
+ module Blorgh
890
+ class ApplicationController < ::ApplicationController
891
+ end
892
892
  end
893
893
  ```
894
894
 
@@ -123,7 +123,7 @@ run the following:
123
123
  $ rails --version
124
124
  ```
125
125
 
126
- If it says something like "Rails 4.2.0", you are ready to continue.
126
+ If it says something like "Rails 4.2.1", you are ready to continue.
127
127
 
128
128
  ### Creating the Blog Application
129
129
 
@@ -318,9 +318,9 @@ root 'welcome#index'
318
318
  application to the welcome controller's index action and `get 'welcome/index'`
319
319
  tells Rails to map requests to <http://localhost:3000/welcome/index> to the
320
320
  welcome controller's index action. This was created earlier when you ran the
321
- controller generator (`rails generate controller welcome index`).
321
+ controller generator (`bin/rails generate controller welcome index`).
322
322
 
323
- Launch the web server again if you stopped it to generate the controller (`rails
323
+ Launch the web server again if you stopped it to generate the controller (`bin/rails
324
324
  server`) and navigate to <http://localhost:3000> in your browser. You'll see the
325
325
  "Hello, Rails!" message you put into `app/views/welcome/index.html.erb`,
326
326
  indicating that this new route is indeed going to `WelcomeController`'s `index`
@@ -353,7 +353,7 @@ Rails.application.routes.draw do
353
353
  end
354
354
  ```
355
355
 
356
- If you run `rake routes`, you'll see that it has defined routes for all the
356
+ If you run `bin/rake routes`, you'll see that it has defined routes for all the
357
357
  standard RESTful actions. The meaning of the prefix column (and other columns)
358
358
  will be seen later, but for now notice that Rails has inferred the
359
359
  singular form `article` and makes meaningful use of the distinction.
@@ -397,7 +397,7 @@ a controller called `ArticlesController`. You can do this by running this
397
397
  command:
398
398
 
399
399
  ```bash
400
- $ bin/rails g controller articles
400
+ $ bin/rails generate controller articles
401
401
  ```
402
402
 
403
403
  If you open up the newly generated `app/controllers/articles_controller.rb`
@@ -551,7 +551,7 @@ this:
551
551
 
552
552
  In this example, the `articles_path` helper is passed to the `:url` option.
553
553
  To see what Rails will do with this, we look back at the output of
554
- `rake routes`:
554
+ `bin/rake routes`:
555
555
 
556
556
  ```bash
557
557
  $ bin/rake routes
@@ -661,7 +661,7 @@ models, as that will be done automatically by Active Record.
661
661
 
662
662
  ### Running a Migration
663
663
 
664
- As we've just seen, `rails generate model` created a _database migration_ file
664
+ As we've just seen, `bin/rails generate model` created a _database migration_ file
665
665
  inside the `db/migrate` directory. Migrations are Ruby classes that are
666
666
  designed to make it simple to create and modify database tables. Rails uses
667
667
  rake commands to run migrations, and it's possible to undo a migration after
@@ -714,7 +714,7 @@ NOTE. Because you're working in the development environment by default, this
714
714
  command will apply to the database defined in the `development` section of your
715
715
  `config/database.yml` file. If you would like to execute migrations in another
716
716
  environment, for instance in production, you must explicitly pass it when
717
- invoking the command: `rake db:migrate RAILS_ENV=production`.
717
+ invoking the command: `bin/rake db:migrate RAILS_ENV=production`.
718
718
 
719
719
  ### Saving data in the controller
720
720
 
@@ -801,7 +801,7 @@ If you submit the form again now, Rails will complain about not finding the
801
801
  `show` action. That's not very useful though, so let's add the `show` action
802
802
  before proceeding.
803
803
 
804
- As we have seen in the output of `rake routes`, the route for `show` action is
804
+ As we have seen in the output of `bin/rake routes`, the route for `show` action is
805
805
  as follows:
806
806
 
807
807
  ```
@@ -831,7 +831,7 @@ class ArticlesController < ApplicationController
831
831
  def new
832
832
  end
833
833
 
834
- # snipped for brevity
834
+ # snippet for brevity
835
835
  ```
836
836
 
837
837
  A couple of things to note. We use `Article.find` to find the article we're
@@ -863,7 +863,7 @@ Visit <http://localhost:3000/articles/new> and give it a try!
863
863
  ### Listing all articles
864
864
 
865
865
  We still need a way to list all our articles, so let's do that.
866
- The route for this as per output of `rake routes` is:
866
+ The route for this as per output of `bin/rake routes` is:
867
867
 
868
868
  ```
869
869
  articles GET /articles(.:format) articles#index
@@ -887,7 +887,7 @@ class ArticlesController < ApplicationController
887
887
  def new
888
888
  end
889
889
 
890
- # snipped for brevity
890
+ # snippet for brevity
891
891
  ```
892
892
 
893
893
  And then finally, add the view for this action, located at
@@ -1357,7 +1357,7 @@ Then do the same for the `app/views/articles/edit.html.erb` view:
1357
1357
 
1358
1358
  We're now ready to cover the "D" part of CRUD, deleting articles from the
1359
1359
  database. Following the REST convention, the route for
1360
- deleting articles as per output of `rake routes` is:
1360
+ deleting articles as per output of `bin/rake routes` is:
1361
1361
 
1362
1362
  ```ruby
1363
1363
  DELETE /articles/:id(.:format) articles#destroy
@@ -1993,7 +1993,7 @@ class ArticlesController < ApplicationController
1993
1993
  @articles = Article.all
1994
1994
  end
1995
1995
 
1996
- # snipped for brevity
1996
+ # snippet for brevity
1997
1997
  ```
1998
1998
 
1999
1999
  We also want to allow only authenticated users to delete comments, so in the
@@ -2009,7 +2009,7 @@ class CommentsController < ApplicationController
2009
2009
  # ...
2010
2010
  end
2011
2011
 
2012
- # snipped for brevity
2012
+ # snippet for brevity
2013
2013
  ```
2014
2014
 
2015
2015
  Now if you try to create a new article, you will be greeted with a basic HTTP
@@ -685,7 +685,7 @@ you can safely pass the username as set by the user:
685
685
 
686
686
  ```erb
687
687
  <%# This is safe, it is going to be escaped if needed. %>
688
- <%= t('welcome_html', username: @current_user.username %>
688
+ <%= t('welcome_html', username: @current_user.username) %>
689
689
  ```
690
690
 
691
691
  Safe strings on the other hand are interpolated verbatim.
@@ -161,7 +161,7 @@ throwing an error message. If the command is valid, a method of the same name
161
161
  is called.
162
162
 
163
163
  ```ruby
164
- COMMAND_WHITELIST = %(plugin generate destroy console server dbconsole application runner new version help)
164
+ COMMAND_WHITELIST = %w(plugin generate destroy console server dbconsole application runner new version help)
165
165
 
166
166
  def run_command!(command)
167
167
  command = parse_command(command)
@@ -805,6 +805,18 @@ As long as `Sprockets` responds to `call` and returns a `[status, headers, body]
805
805
 
806
806
  NOTE: For the curious, `'articles#index'` actually expands out to `ArticlesController.action(:index)`, which returns a valid Rack application.
807
807
 
808
+ If you specify a rack application as the endpoint for a matcher remember that the route will be unchanged in the receiving application. With the following route your rack application should expect the route to be '/admin':
809
+
810
+ ```ruby
811
+ match '/admin', to: AdminApp, via: :all
812
+ ```
813
+
814
+ If you would prefer to have your rack application receive requests at the root path instead use mount:
815
+
816
+ ```ruby
817
+ mount AdminApp, at: '/admin'
818
+ ```
819
+
808
820
  ### Using `root`
809
821
 
810
822
  You can specify what Rails should route `'/'` to with the `root` method:
@@ -838,6 +838,20 @@ this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
838
838
 
839
839
  * To re-enable the old finders, you can use the [activerecord-deprecated_finders gem](https://github.com/rails/activerecord-deprecated_finders).
840
840
 
841
+ * Rails 4.0 has changed to default join table for `has_and_belongs_to_many` relations to strip the common prefix off the second table name. Any existing `has_and_belongs_to_many` relationship between models with a common prefix must be specified with the `join_table` option. For example:
842
+
843
+ ```ruby
844
+ CatalogCategory < ActiveRecord::Base
845
+ has_and_belongs_to_many :catalog_products, join_table: 'catalog_categories_catalog_products'
846
+ end
847
+
848
+ CatalogProduct < ActiveRecord::Base
849
+ has_and_belongs_to_many :catalog_categories, join_table: 'catalog_categories_catalog_products'
850
+ end
851
+ ```
852
+
853
+ * Note that the the prefix takes scopes into account as well, so relations between `Catalog::Category` and `Catalog::Product` or `Catalog::Category` and `CatalogProduct` need to be updated similarly.
854
+
841
855
  ### Active Resource
842
856
 
843
857
  Rails 4.0 extracted Active Resource to its own gem. If you still need the feature you can add the [Active Resource gem](https://github.com/rails/activeresource) in your Gemfile.
@@ -881,6 +895,8 @@ Please read [Pull Request #9978](https://github.com/rails/rails/pull/9978) for d
881
895
 
882
896
  * Rails 4.0 has removed the XML parameters parser. You will need to add the `actionpack-xml_parser` gem if you require this feature.
883
897
 
898
+ * Rails 4.0 changes the default `layout` lookup set using symbols or procs that return nil. To get the "no layout" behavior, return false instead of nil.
899
+
884
900
  * Rails 4.0 changes the default memcached client from `memcache-client` to `dalli`. To upgrade, simply add `gem 'dalli'` to your `Gemfile`.
885
901
 
886
902
  * Rails 4.0 deprecates the `dom_id` and `dom_class` methods in controllers (they are fine in views). You will need to include the `ActionView::RecordIdentifier` module in controllers requiring this feature.
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.2
4
+ version: 4.2.3.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: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-06-22 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.2
19
+ version: 4.2.3.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.2
26
+ version: 4.2.3.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.2
33
+ version: 4.2.3.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.2
40
+ version: 4.2.3.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.2
47
+ version: 4.2.3.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.2
54
+ version: 4.2.3.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.2
61
+ version: 4.2.3.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.2
68
+ version: 4.2.3.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.2
75
+ version: 4.2.3.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.2
82
+ version: 4.2.3.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.2
89
+ version: 4.2.3.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.2
96
+ version: 4.2.3.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.2
103
+ version: 4.2.3.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.2
110
+ version: 4.2.3.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.2
117
+ version: 4.2.3.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.2
124
+ version: 4.2.3.rc1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -308,6 +308,8 @@ files:
308
308
  - guides/bug_report_templates/action_controller_master.rb
309
309
  - guides/bug_report_templates/active_record_gem.rb
310
310
  - guides/bug_report_templates/active_record_master.rb
311
+ - guides/bug_report_templates/generic_gem.rb
312
+ - guides/bug_report_templates/generic_master.rb
311
313
  - guides/rails_guides.rb
312
314
  - guides/rails_guides/generator.rb
313
315
  - guides/rails_guides/helpers.rb