diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-02-20 20:22:42 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-02-21 15:30:47 +0000 |
commit | 3bf47b018be912fc7946342315e67b2ac6c33eaf (patch) | |
tree | 4973296ac024fdf8ead9d2f80230a7c9c0785810 /actionview | |
parent | d67e2520289745913e7bab9a852c86b99245f738 (diff) | |
download | rails-3bf47b018be912fc7946342315e67b2ac6c33eaf.tar.gz rails-3bf47b018be912fc7946342315e67b2ac6c33eaf.tar.bz2 rails-3bf47b018be912fc7946342315e67b2ac6c33eaf.zip |
Add custom polymorphic mapping
Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g:
resource :basket
direct(class: "Basket") { [:basket] }
This will then generate the following:
>> link_to "Basket", @basket
=> <a href="/basket">Basket</a>
More importantly it will generate the correct url when used with `form_for`.
Fixes #1769.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 2b981caa65..ae4fec4337 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -124,6 +124,10 @@ module ActionView @_rendered_views ||= RenderedViewsCollection.new end + def _routes + @controller._routes if @controller.respond_to?(:_routes) + end + # Need to experiment if this priority is the best one: rendered => output_buffer class RenderedViewsCollection def initialize @@ -258,10 +262,6 @@ module ActionView end] end - def _routes - @controller._routes if @controller.respond_to?(:_routes) - end - def method_missing(selector, *args) begin routes = @controller.respond_to?(:_routes) && @controller._routes |