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.

[PATCH] #controller_path returns empty string in Ruby 1.8.7

#4036

Actually it returns an empty string in this particular code:

require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require
require 'action_controller'

name = 'ExamplesController'
class_name = name.camelize
klass = Class.new(ActionController::Base)
Object.const_set(class_name, klass)
controller = klass.new

p controller.class.name
=> "ExamplesController" in Ruby 1.8.7 and 1.9.1

p controller.controller_path
=> "" in Ruby 1.8.7
=> "examples" in Ruby 1.9.1

This problem occurs only in Rails 3.0 (I'm using master branch - that's why bundler is used here). In Rails 2.3.5 it works correctly.

Reported by Szymon Nowak · February 22nd, 2010 @ 05:34 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Szymon Nowak
    Szymon Nowak
    • Tag changed from ruby 1.8.7, 3.0, action_controller to ruby 1.8.7, 3.0, action_controller, patch

    For some strange reason in Ruby 1.8.7 at some point class.name is just an empty string, so @controller_path in AbstractController::Base is also set to an empty string.

    This patch should fix this problem.

    February 23rd, 2010 @ 09:04 AM

  2. Szymon Nowak
    Szymon Nowak
    • Title changed from #controller_path returns empty string in Ruby 1.8.7 to [PATCH] #controller_path returns empty string in Ruby 1.8.7

    February 23rd, 2010 @ 09:06 AM

  3. José Valim
    José Valim
    • Assigned user set to José Valim
    • Milestone cleared.

    February 23rd, 2010 @ 09:05 PM

  4. José Valim
    José Valim
    • State changed from new to resolved

    Just committed a different fix and added tests. Thanks!

    February 26th, 2010 @ 10:52 AM

  5. Repository
  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM