Permalink
Browse files

Get rid of constant name usage for stack trace help in favor of overr…

…iding #inspect and .name.
  • Loading branch information...
wycats committed Oct 9, 2009
1 parent 69aa5e8 commit ee37ff46e9ad381a8331a6a3deed001b001f75ee
Showing with 9 additions and 9 deletions.
  1. +9 −9 actionpack/lib/action_view/base.rb
@@ -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)

3 comments on commit ee37ff4

@masterkain

This comment has been minimized.

Show comment Hide comment
@masterkain

masterkain Oct 14, 2009

Contributor

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

trace: http://pastie.org/655201

Contributor

masterkain replied Oct 14, 2009

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

trace: http://pastie.org/655201

@masterkain

This comment has been minimized.

Show comment Hide comment
@masterkain

masterkain Oct 14, 2009

Contributor

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

Contributor

masterkain replied Oct 14, 2009

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

@masterkain

This comment has been minimized.

Show comment Hide comment
@masterkain

masterkain Oct 14, 2009

Contributor

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".

Contributor

masterkain replied Oct 14, 2009

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.