From a132229d7b4382d9ffe8847fa58f469cb8f2ecfc Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 22 Jul 2010 22:11:32 +0200 Subject: Added ability to set asset_path for engines --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index a3c43d3e93..3329a8b368 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -727,6 +727,9 @@ module ActionView source += ".#{ext}" if rewrite_extension?(source, dir, ext) source = "/#{dir}/#{source}" unless source[0] == ?/ + if controller.respond_to?(:env) && controller.env["action_dispatch.asset_path"] + source = rewrite_asset_path(source, controller.env["action_dispatch.asset_path"]) + end source = rewrite_asset_path(source, config.asset_path) has_request = controller.respond_to?(:request) -- cgit v1.2.3 From befa77fc18ba54c1be89553466312039c1073f02 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 2 Aug 2010 02:55:01 +0200 Subject: Fix generating urls with mounted helpers in view context There were actually 2 problems with this one: * script_name was added to options as a string and then it was used in RouteSet#url_for with usage of <<, which was changing the original script_name * the second issue was with _with_routes method. It was called in RoutesProxy to modify _routes in view_context, but url_helpers in views is just delegating it to controller, so another _with_routes call is needed there --- actionpack/lib/action_view/helpers/url_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index b8df2d9a69..f21cffea26 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -29,7 +29,9 @@ module ActionView # def url_options return super unless controller.respond_to?(:url_options) - controller.url_options + controller.send(:_with_routes, _routes) do + controller.url_options + end end # Returns the URL for the set of +options+ provided. This takes the -- cgit v1.2.3 From f3c703a32f6c7833705e46b8e14f172330a1c916 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 4 Aug 2010 16:20:56 +0200 Subject: Refactor RoutesProxy to avoid using _with_routes in helpers --- actionpack/lib/action_view/helpers/url_helper.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index f21cffea26..555be6ed2b 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -22,6 +22,10 @@ module ActionView include ActionDispatch::Routing::UrlFor include TagHelper + def _routes_context + controller + end + # Need to map default url options to controller one. # def default_url_options(*args) #:nodoc: # controller.send(:default_url_options, *args) @@ -29,9 +33,7 @@ module ActionView # def url_options return super unless controller.respond_to?(:url_options) - controller.send(:_with_routes, _routes) do - controller.url_options - end + controller.url_options end # Returns the URL for the set of +options+ provided. This takes the -- cgit v1.2.3 From 6f3119d3c298c007e7a4eed8375d9fc30b961d06 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 1 Sep 2010 01:37:02 +0200 Subject: Remove namespace for isolated namespaced models in forms --- actionpack/lib/action_view/helpers/form_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 94dc25eb85..43dbedc448 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -304,12 +304,12 @@ module ActionView object_name = record_or_name_or_array when Array object = record_or_name_or_array.last - object_name = options[:as] || ActiveModel::Naming.singular(object) + object_name = options[:as] || ActiveModel::Naming.param_key(object) apply_form_for_options!(record_or_name_or_array, options) args.unshift object else object = record_or_name_or_array - object_name = options[:as] || ActiveModel::Naming.singular(object) + object_name = options[:as] || ActiveModel::Naming.param_key(object) apply_form_for_options!([object], options) args.unshift object end @@ -539,7 +539,7 @@ module ActionView object_name = record else object = record - object_name = ActiveModel::Naming.singular(object) + object_name = ActiveModel::Naming.param_key(object) end builder = options[:builder] || ActionView::Base.default_form_builder @@ -1168,11 +1168,11 @@ module ActionView end when Array object = record_or_name_or_array.last - name = "#{object_name}#{index}[#{ActiveModel::Naming.singular(object)}]" + name = "#{object_name}#{index}[#{ActiveModel::Naming.param_key(object)}]" args.unshift(object) else object = record_or_name_or_array - name = "#{object_name}#{index}[#{ActiveModel::Naming.singular(object)}]" + name = "#{object_name}#{index}[#{ActiveModel::Naming.param_key(object)}]" args.unshift(object) end -- cgit v1.2.3