Skip to content

Commit

Permalink
Get rid of constant name usage for stack trace help in favor of overr…
Browse files Browse the repository at this point in the history
…iding #inspect and .name.
  • Loading branch information
wycats committed Oct 9, 2009
1 parent 69aa5e8 commit ee37ff4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions actionpack/lib/action_view/base.rb
Expand Up @@ -236,15 +236,15 @@ def self.for_controller(controller)
# they are in AC.
if controller.class.respond_to?(:_helper_serial)
klass = @views[controller.class._helper_serial] ||= Class.new(self) do
name = controller.class.name.gsub(/::/, '__')

Subclasses.class_eval do
if method(:const_defined?).arity == 1
remove_const(name) if const_defined?(name) # Ruby 1.8.x
else
remove_const(name) if const_defined?(name, false) # Ruby 1.9.x
end
const_set(name, self)
const_set(:CONTROLLER_CLASS, controller.class)

# Try to make stack traces clearer
def self.name
"ActionView for #{CONTROLLER_CLASS}"
end

def inspect
"#<#{self.class.name}>"
end

if controller.respond_to?(:_helpers)
Expand Down

3 comments on commit ee37ff4

@masterkain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting uninitialized constant ActionView::Base::CONTROLLER_CLASS .

trace: http://pastie.org/655201

@masterkain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot: using ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]

@masterkain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code fails for me in two points:

  1. on L243 it can't find CONTROLLER_CLASS because for some reason it doesn't get defined properly on my system.

  2. the second is that at some point activesupport/lib/active_support/configurable.rb will call modules.last.const_get(name) and if CONTROLLER_CLASS is defined will raise wrong constant name on string "ActionView for MyController".

Please sign in to comment.