From 960e73a96df55aecfaf196e35df80f8f0121f51d Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 20 Feb 2017 20:39:56 +0000 Subject: Add CHANGELOG entry for `direct` method --- actionpack/CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'actionpack/CHANGELOG.md') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 327852e75e..73c30aa9b0 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,42 @@ +* Add the `direct` method to the routing DSL + + This new method allows customization of the routing behavior in two ways: + + 1. Custom url helpers: + + ``` ruby + direct(:apple) { "http://www.apple.com" } + + >> apple_url + => "http://www.apple.com" + ``` + + This has the advantage of being available everywhere url helpers are available + unlike custom url helpers defined in helper modules, etc. + + 2. Custom polymorphic mappings: + + ``` ruby + resource :basket + direct(class: "Basket") { [:basket] } + ``` + + ``` erb + <%= form_for @basket do |form| %> + + <% end %> + ``` + + This generates the correct singular URL for the form instead of the default + resources member url, e.g. `/basket` vs. `/basket/:id`. + + Currently both forms of `direct` do not take anything from the current routing + scope so it's recommended to declare them outside of any `namespace` or `scope` block. + + Fixes #1769. + + *Andrew White* + * Add `ActionDispatch::SystemTestCase` to Action Pack Adds Capybara integration directly into Rails through Action Pack! -- cgit v1.2.3 From c116eaf2217abbc83ad76ac09c4fb89e033e1cdd Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 21 Feb 2017 12:49:25 +0000 Subject: Prefer remove_method over undef_method Using `undef_method` means that when a route is removed any other implementations of that method in the ancestor chain are inaccessible so instead use `remove_method` which restores access to the ancestor. --- actionpack/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/CHANGELOG.md') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 73c30aa9b0..869fc7d484 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,10 @@ +* Prefer `remove_method` over `undef_method` when reloading routes + + When `undef_method` is used it prevents access to other implementations of that + url helper in the ancestor chain so use `remove_method` instead to restores access. + + *Andrew White* + * Add the `direct` method to the routing DSL This new method allows customization of the routing behavior in two ways: -- cgit v1.2.3 From d7c1e62c2cd2969b991bc4a1150b02b27f6d6e3f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 21 Feb 2017 15:29:10 +0000 Subject: Split direct method into two Use a separate method called `resolve` for the custom polymorphic mapping to clarify the API. --- actionpack/CHANGELOG.md | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'actionpack/CHANGELOG.md') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 869fc7d484..8226a5be47 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -5,42 +5,41 @@ *Andrew White* -* Add the `direct` method to the routing DSL +* Add the `resolve` method to the routing DSL - This new method allows customization of the routing behavior in two ways: + This new method allows customization of the polymorphic mapping of models: - 1. Custom url helpers: + ``` ruby + resource :basket + direct(class: "Basket") { [:basket] } + ``` - ``` ruby - direct(:apple) { "http://www.apple.com" } + ``` erb + <%= form_for @basket do |form| %> + + <% end %> + ``` - >> apple_url - => "http://www.apple.com" - ``` + This generates the correct singular URL for the form instead of the default + resources member url, e.g. `/basket` vs. `/basket/:id`. - This has the advantage of being available everywhere url helpers are available - unlike custom url helpers defined in helper modules, etc. + Fixes #1769. - 2. Custom polymorphic mappings: + *Andrew White* - ``` ruby - resource :basket - direct(class: "Basket") { [:basket] } - ``` +* Add the `direct` method to the routing DSL - ``` erb - <%= form_for @basket do |form| %> - - <% end %> - ``` + This new method allows creation of custom url helpers, e.g: - This generates the correct singular URL for the form instead of the default - resources member url, e.g. `/basket` vs. `/basket/:id`. + ``` ruby + direct(:apple) { "http://www.apple.com" } - Currently both forms of `direct` do not take anything from the current routing - scope so it's recommended to declare them outside of any `namespace` or `scope` block. + >> apple_url + => "http://www.apple.com" + ``` - Fixes #1769. + This has the advantage of being available everywhere url helpers are available + unlike custom url helpers defined in helper modules, etc. *Andrew White* -- cgit v1.2.3