This project is archived and is in readonly mode.
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
-
deviated June 19th, 2010 @ 08:15 AM
Valid
-tried this on irb 0.9.5 and it prints this outirb(main):014:0> Hello.say
NoMethodError: undefined methodsay' for Hi:Class<br/>
from (irb):11:in `say' from (irb):14 from /usr/local/bin/irb:12:in `<main>'
*replaced 'controller_path' with say (doesn't matter what say does) basically did the same thing like he did, and it fails where his
succeeds. -
José Valim June 21st, 2010 @ 10:21 AM
- Milestone cleared.
- Assigned user set to José Valim
Could you please provide a patch with tests?
-
knapo June 22nd, 2010 @ 07:50 PM
There you go!
I guess that new tests related to this stuff should be included into test/controller/new_base/base_test.rb not in test/controller/base_test.rb or both?
-
José Valim June 22nd, 2010 @ 08:26 PM
You can add tests to any. The general idea is, new_base holds tests for stuff added specifically on Rails 3. base_test is since Rails early days. If you want me to pick one, I would say: go test/controller/base_test.rb :)
-
knapo June 22nd, 2010 @ 09:47 PM
The reason I chose test/controller/new_base/base_test.rb is that I noticed that many tests (inc. controller_path, and controller_name related) in this file are duplicated between both test files (rewritten to new TestUnit syntax) with ones from test/controller/base_test.rb. So I thought that test/controller/base_test.rb is gonna to be replaced with new_base/base_test.rb :)
-
Repository June 23rd, 2010 @ 12:40 AM
- State changed from new to resolved
(from [995b1a243cf8450b976eb40613f5cb703a22159a]) Fix controller_name for non default controller paths [#4901 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/995b1a243cf8450b976eb40613f5cb...
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>
People watching this ticket
Attachments
Referenced by
- 4901 controller_name is invalid when controller_path changes (from [995b1a243cf8450b976eb40613f5cb703a22159a]) Fix con...