aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-03 17:36:08 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-03 21:24:01 -0800
commitb160663bd13d08bf845bc8cdf87a2c5e7e46f901 (patch)
tree5144a55d7169b42132a878a65a583d9472b3b0b3 /actionpack/lib
parent54302ef55bffd1a93f20f5d1ae81217b2e4149c4 (diff)
downloadrails-b160663bd13d08bf845bc8cdf87a2c5e7e46f901.tar.gz
rails-b160663bd13d08bf845bc8cdf87a2c5e7e46f901.tar.bz2
rails-b160663bd13d08bf845bc8cdf87a2c5e7e46f901.zip
Start refactoring the method of configuring ActionView
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/railtie.rb14
-rw-r--r--actionpack/lib/action_view/base.rb12
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb7
-rw-r--r--actionpack/lib/action_view/test_case.rb4
4 files changed, 20 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb
index 07c6b8f2b6..f4c51ba760 100644
--- a/actionpack/lib/action_controller/railtie.rb
+++ b/actionpack/lib/action_controller/railtie.rb
@@ -17,7 +17,21 @@ module ActionController
ActionController::Base.logger ||= Rails.logger
end
+ # assets_dir = defined?(Rails.public_path) ? Rails.public_path : "public"
+ # ActionView::DEFAULT_CONFIG = {
+ # :assets_dir => assets_dir,
+ # :javascripts_dir => "#{assets_dir}/javascripts",
+ # :stylesheets_dir => "#{assets_dir}/stylesheets",
+ # }
+
+
initializer "action_controller.set_configs" do |app|
+ paths = app.config.paths
+ ac = app.config.action_controller
+ ac.assets_dir = paths.public
+ ac.javascripts_dir = paths.public.javascripts
+ ac.stylesheets_dir = paths.public.stylesheets
+
app.config.action_controller.each do |k,v|
ActionController::Base.send "#{k}=", v
end
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 2d2b53a6ce..87a1972fb4 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -175,15 +175,6 @@ module ActionView #:nodoc:
include Helpers, Rendering, Partials, ::ERB::Util
- def config
- self.config = DEFAULT_CONFIG unless @config
- @config
- end
-
- def config=(config)
- @config = ActiveSupport::OrderedOptions.new.merge(config)
- end
-
extend ActiveSupport::Memoizable
attr_accessor :base_path, :assigns, :template_extension
@@ -306,12 +297,13 @@ module ActionView #:nodoc:
@helpers = self.class.helpers || Module.new
@_controller = controller
+ @_config = controller.config if controller
@_content_for = Hash.new {|h,k| h[k] = ActiveSupport::SafeBuffer.new }
@_virtual_path = nil
self.view_paths = view_paths
end
- attr_internal :controller, :template
+ attr_internal :controller, :template, :config
attr_reader :view_paths
def view_paths=(paths)
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 5f76ff456e..b52d255d1f 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -133,13 +133,6 @@ module ActionView
# change. You can use something like Live HTTP Headers for Firefox to verify
# that the cache is indeed working.
module AssetTagHelper
- assets_dir = defined?(Rails.public_path) ? Rails.public_path : "public"
- ActionView::DEFAULT_CONFIG = {
- :assets_dir => assets_dir,
- :javascripts_dir => "#{assets_dir}/javascripts",
- :stylesheets_dir => "#{assets_dir}/stylesheets",
- }
-
JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls', 'rails'].freeze unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES)
# Returns a link tag that browsers and news readers can use to auto-detect
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 12142a3728..72dbead14b 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -62,6 +62,10 @@ module ActionView
make_test_case_available_to_view!
end
+ def config
+ @controller.config
+ end
+
def render(options = {}, local_assigns = {}, &block)
@rendered << output = _view.render(options, local_assigns, &block)
output