From d717882eb501510b8367382ea7d6c0097aac38cf Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Tue, 12 Mar 2013 15:07:17 -0500 Subject: Document change to clashing named route selection from journey commit 98a9802a --- guides/source/upgrading_ruby_on_rails.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'guides/source/upgrading_ruby_on_rails.md') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index cb43781f52..0941bc7e58 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -103,6 +103,32 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur * Rails 4.0 changed how `assert_generates`, `assert_recognizes`, and `assert_routing` work. Now all these assertions raise `Assertion` instead of `ActionController::RoutingError`. +* Rails 4.0 correctly prefers the first named route defined in `config/routes.rb` if a clashing route is found later. Check the output of `rake routes` before upgrading and remove unused named routes to avoid issues. + +```ruby + # config/routes.rb + get 'one' => 'test#example', as: :example + get 'two' => 'test#example', as: :example + + # Rails 3 + <%= example_path %> # => '/two' + + # Rails 4 + <%= example_path %> # => '/one' +``` + +```ruby + # config/routes.rb + resources :examples + get 'clashing/:id' => 'test#example', as: :example + + # Rails 3 + <%= example_path(1) %> # => '/clashing/1' + + # Rails 4 + <%= example_path(1) %> # => '/examples/1' +``` + * Rails 4.0 also changed the way unicode character routes are drawn. Now you can draw unicode character routes directly. If you already draw such routes, you must change them, for example: ```ruby -- cgit v1.2.3 From a2b7c0e69d671294067b625c749be6fdbec7b433 Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Tue, 19 Mar 2013 23:23:55 -0500 Subject: Raise an ArgumentError when a clashing named route is defined --- guides/source/upgrading_ruby_on_rails.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'guides/source/upgrading_ruby_on_rails.md') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 0941bc7e58..af223873ec 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -103,32 +103,20 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur * Rails 4.0 changed how `assert_generates`, `assert_recognizes`, and `assert_routing` work. Now all these assertions raise `Assertion` instead of `ActionController::RoutingError`. -* Rails 4.0 correctly prefers the first named route defined in `config/routes.rb` if a clashing route is found later. Check the output of `rake routes` before upgrading and remove unused named routes to avoid issues. +* Rails 4.0 raises an `ArgumentError` if clashing named routes are defined. This can be triggered by explicitly defined named routes or by the `resources` method. Here are two examples that clash with routes named `example_path`: ```ruby - # config/routes.rb get 'one' => 'test#example', as: :example get 'two' => 'test#example', as: :example - - # Rails 3 - <%= example_path %> # => '/two' - - # Rails 4 - <%= example_path %> # => '/one' ``` ```ruby - # config/routes.rb resources :examples get 'clashing/:id' => 'test#example', as: :example - - # Rails 3 - <%= example_path(1) %> # => '/clashing/1' - - # Rails 4 - <%= example_path(1) %> # => '/examples/1' ``` +In the first case, you can simply avoid using the same name for multiple routes. In the second, you can use the `only` or `except` options provided by the `resources` method to restrict the routes created as detailed in the [Routing Guide](http://guides.rubyonrails.org/routing.html#restricting-the-routes-created). + * Rails 4.0 also changed the way unicode character routes are drawn. Now you can draw unicode character routes directly. If you already draw such routes, you must change them, for example: ```ruby -- cgit v1.2.3 From 0190cba99c9d3367cfba9b2d1901633715fa314c Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Sun, 24 Mar 2013 18:20:24 -0500 Subject: Introduce UpgradeLegacySignedCookieJar to transparently upgrade existing signed cookies generated by Rails 3 to avoid invalidating them when upgrading to Rails 4 --- guides/source/upgrading_ruby_on_rails.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'guides/source/upgrading_ruby_on_rails.md') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index af223873ec..a384e74d28 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -78,7 +78,17 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur ### Action Pack -* Rails 4.0 introduces a new `UpgradeSignatureToEncryptionCookieStore` cookie store. This is useful for upgrading apps using the old default `CookieStore` to the new default `EncryptedCookieStore`. To use this transitional cookie store, you'll want to leave your existing `secret_token` in place, add a new `secret_key_base`, and change your `session_store` like so: +* Rails 4.0 introduces `ActiveSupport::KeyGenerator` and uses this as a base from which to generate and verify signed cookies (among other things). Existing signed cookies generated with Rails 3.x will be transparently upgraded if you leave your existing `secret_token` in place and add the new `secret_key_base`. + +```ruby + # config/initializers/secret_token.rb + Myapp::Application.config.secret_token = 'existing secret token' + Myapp::Application.config.secret_key_base = 'new secret key base' +``` + +Please note that you should wait to set `secret_key_base` until you have 100% of your userbase on Rails 4.x and are reasonably sure you will not need to rollback to Rails 3.x. This is because cookies signed based on the new `secret_key_base` in Rails 4.x are not backwards compatible with Rails 3.x. You are free to leave your existing `secret_token` in place, not set the new `secret_key_base`, and ignore the deprecation warnings until you are reasonably sure that your upgrade is otherwise complete. + +* Rails 4.0 introduces a new `UpgradeSignatureToEncryptionCookieStore` cookie store. This is useful for upgrading apps using the old default `CookieStore` to the new default `EncryptedCookieStore` which leverages the new `ActiveSupport::KeyGenerator`. To use this transitional cookie store, you'll want to leave your existing `secret_token` in place, add a new `secret_key_base`, and change your `session_store` like so: ```ruby # config/initializers/session_store.rb -- cgit v1.2.3 From 441fa86b73f191494d6734ffd51a5b6b986574cb Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 25 Mar 2013 20:00:13 +0100 Subject: use relative links inside guides [ci skip] --- guides/source/upgrading_ruby_on_rails.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guides/source/upgrading_ruby_on_rails.md') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index a384e74d28..8ad2e2bdb4 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -125,7 +125,10 @@ Please note that you should wait to set `secret_key_base` until you have 100% of get 'clashing/:id' => 'test#example', as: :example ``` -In the first case, you can simply avoid using the same name for multiple routes. In the second, you can use the `only` or `except` options provided by the `resources` method to restrict the routes created as detailed in the [Routing Guide](http://guides.rubyonrails.org/routing.html#restricting-the-routes-created). +In the first case, you can simply avoid using the same name for multiple +routes. In the second, you can use the `only` or `except` options provided by +the `resources` method to restrict the routes created as detailed in the +[Routing Guide](routing.html#restricting-the-routes-created). * Rails 4.0 also changed the way unicode character routes are drawn. Now you can draw unicode character routes directly. If you already draw such routes, you must change them, for example: -- cgit v1.2.3