1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix controller_path returnsing an empty string in Ruby 1.8.7 [#4036 status:resolved]

This commit is contained in:
José Valim 2010-02-26 11:51:21 +01:00
parent 4db72b702f
commit bd36418c51
7 changed files with 15 additions and 12 deletions

View file

@ -3,8 +3,10 @@ $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.inc
require 'active_support/ruby/shim'
require 'active_support/dependencies/autoload'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/anonymous'
module AbstractController
extend ActiveSupport::Autoload

View file

@ -84,7 +84,7 @@ module AbstractController
# ==== Returns
# String
def controller_path
@controller_path ||= name && name.sub(/Controller$/, '').underscore
@controller_path ||= name.sub(/Controller$/, '').underscore unless anonymous?
end
end

View file

@ -1,7 +1,4 @@
require 'active_support/dependencies'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/anonymous'
module AbstractController
module Helpers

View file

@ -1,6 +1,3 @@
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
module AbstractController
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
# repeated setups. The inclusion pattern has pages that look like this:

View file

@ -1,5 +1,5 @@
require 'active_support/core_ext/logger'
require 'active_support/benchmarkable'
require "active_support/core_ext/logger"
require "active_support/benchmarkable"
module AbstractController
module Logger

View file

@ -1,7 +1,5 @@
require "abstract_controller/base"
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/array/wrap'
require "active_support/core_ext/array/wrap"
module AbstractController
class DoubleRenderError < Error

View file

@ -113,6 +113,15 @@ class ControllerInstanceTests < Test::Unit::TestCase
assert_equal Set.new(%w(public_action)), c.class.__send__(:action_methods), "#{c.controller_path} should not be empty!"
end
end
def test_temporary_anonymous_controllers
name = 'ExamplesController'
klass = Class.new(ActionController::Base)
Object.const_set(name, klass)
controller = klass.new
assert_equal "examples", controller.controller_path
end
end
class PerformActionTest < ActionController::TestCase