This project is archived and is in readonly mode.

#4901 ✓resolved
knapo

controller_name is invalid when controller_path changes

Reported by knapo | June 18th, 2010 @ 06:00 PM | in 3.0.2

For some reason controller_name was changed to return last part of controller_path:

controller_path.split("/").last

What fails when controller_path is not default, e.g:

class MeatsController < ActionController::Base
end

class SteaksController < MeatsController
  def self.controller_path
    self.superclass.controller_path
  end
end

irb(main):009:0> MeatsController.controller_name
=> "meats"
irb(main):010:0> SteaksController.controller_name
=> "meats"

Rails 2.x implementation is more proper and returns real controller_name:

@controller_name ||= self.class.name.demodulize.sub(/Controller$/, '').underscore

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages