Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionController::Base.class_eval clobbers config.action_view value

#6243

Calling ActionController::Base.class_eval clobbers the value of
Foobar::Application.config.action_view.

% rails new foobar > /dev/null
% cd foobar
% rails c
Loading development environment (Rails 3.0.3)
ruby-1.9.2-p136 > Foobar::Application.config.action_view
 => {:stylesheet_expansions=>{}, :javascript_expansions=>{:defaults=>["prototype", "effects", "dragdrop", "controls", "rails"]}, :debug_rjs=>true} 
ruby-1.9.2-p136 > ActionController::Base.class_eval {}
 => nil 
ruby-1.9.2-p136 > Foobar::Application.config.action_view
 => {:debug_rjs=>true} 
ruby-1.9.2-p136 > quit
%

Below is a script that highlights one potential source for
the issue.

require 'rubygems'
gem 'rails', '3.0.3'
require 'rails/all'

module Rails
  module Initializable
    class Initializer
      def run(*args)
        # remove the next line to see action_view get clobbered
        return if :add_view_paths == @name
        @context.instance_exec(*args, &block)
      end
    end
  end
end
module Foobar; class Application < Rails::Application; end; end

Foobar::Application.initialize!
puts Foobar::Application.config.action_view
ActionController::Base.class_eval {}
puts Foobar::Application.config.action_view

Reported by Steve Price · December 31st, 2010 @ 11:19 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Steve Price
    Steve Price

    Here's a patch that resolves the issue here. I'm investigating
    whether the 'action_view.set_configs' initializer should go away
    as well.

    diff --git a/actionpack/lib/action_view/railtie.rb b/actionpack/lib/action_view/railtie.rb
    index 501ec07..99eaecd 100644
    --- a/actionpack/lib/action_view/railtie.rb
    +++ b/actionpack/lib/action_view/railtie.rb
    @@ -16,22 +16,11 @@ module ActionView
           end
         end
     
    -    initializer "action_view.javascript_expansions" do |app|
    -      ActiveSupport.on_load(:action_view) do
    -        ActionView::Helpers::AssetTagHelper.register_javascript_expansion(
    -          app.config.action_view.delete(:javascript_expansions)
    -        )
    -
    -        ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion(
    -          app.config.action_view.delete(:stylesheet_expansions)
    -        )
    -      end
    -    end
    -
         initializer "action_view.set_configs" do |app|
           ActiveSupport.on_load(:action_view) do
             app.config.action_view.each do |k,v|
    -          send "#{k}=", v
    +          send "#{k}=", v unless [:javascript_expansions,
    +            :stylesheet_expansions].include? k
             end
           end
         end
    

    January 1st, 2011 @ 03:59 AM

  2. mikle
    mikle

    michael jordan basketball shoes Jumpman23 Jordan,new jordan releases 2009 authentic retro jordan,jordan shoes for girls Authentic Retro Jordan Shoes,new michael jordan shoes Jordans For Sale,Buy Jordan sneakers Online,michael jordan sneakers Authentic Space Jams,cheap air force ones Authentic Jordans,michael jordan pictures Authentic Retro Jordan Shoes,custom air force ones Cheap Jordan Retro Shoes,buy wholesale products from Chinese Jumpman23 shoes .jordan air force ones Authentic Cheap Jordans,jordan shoes release dates Authentic Air Jordan Shoes,new jordan releases Authentic Air Jordans Authentic Jordan Air Shoes Air Retro Jordans Shoes.Air Jordan Sneakers.buy air jordans online.Cheap Nike Dunk Kicks.

    January 21st, 2011 @ 05:59 AM