This project is archived and is in readonly mode.
Possible bug with uncountable inflections and namedspace routes?
Reported by omarqureshi | March 19th, 2010 @ 12:00 AM | in 3.0.2
If i have an uncountable inflection (in this case "content"), and i was then to add a namespace with a resource named after that inflection to correspond to a model (of that very same name!), e.g:
e.g.
routes.rb
---------
namespace :admin do
resources :content
end
content_controller.rb
---------------------
class Admin::ContentController < ApplicationController
def new
@content = Content.new
end
end
I get the following:
1) Error: test_get_new(Admin::ContentControllerTest):
NoMethodError: undefined method new' for
Admin::Content:Module<br/>
/Users/omarqureshi/Sites/Ruby191/content-menage/app/controllers/admin/content_controller.rb:8:in `new'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/abstract_controller/base.rb:153:in `process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/rendering.rb:11:in `process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/callbacks.rb:433:in `_run__77664824__process_action__2035442755__callbacks'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/callbacks.rb:423:in `_run_process_action_callbacks'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/callbacks.rb:88:in `run_callbacks'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `block in process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/notifications.rb:53:in `instrument'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/rescue.rb:8:in `process_action'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/abstract_controller/base.rb:123:in `process'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/abstract_controller/rendering.rb:41:in `process'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/test_case.rb:350:in `process'
/Users/omarqureshi/.rvm/gems/ruby-1.9.1-p378%rails3/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_controller/test_case.rb:288:in `get'
/Users/omarqureshi/Sites/Ruby191/content-menage/test/functional/admin/content_controller_test.rb:6:in `block in <class:ContentControllerTest>'
I definitely do NOT have a module called Admin::Content defined in my app or in any gems that I am using (just haml and pg). Fiddling with the resource - e.g. changing it from resources :content to resources :contents, works - however, that is NOT what I am after here, trying to define singular and plural path names doesn't seem to do anything either.
I believe this bug is different from https://rails.lighthouseapp.com/projects/8994/tickets/3930-uncounta...
Comments and changes to this ticket
-
omarqureshi March 19th, 2010 @ 12:03 AM
- Tag set to inflections, rails3, routing, uncountable
-
José Valim March 27th, 2010 @ 01:56 PM
This is completely odd. Can you try to isolate the issue? In the meanwhile, I recommend you to use ::Content instead of Content.
-
José Valim March 28th, 2010 @ 06:27 AM
- Milestone cleared.
- Assigned user set to José Valim
And please try "defined?(Admin::Console)" in
rails console
. Maybe the module is defined somewhere else? -
Yehuda Katz (wycats) March 29th, 2010 @ 01:13 AM
- State changed from new to needs-more-info
-
omarqureshi March 29th, 2010 @ 01:34 PM
defined?(Admin::Content) in the console from when I was trying to debug it returned false - what I had done is moved work on the app back to 2.3.5 temporarily which worked fine.
I will move it back to 3 beta and stick on github as proof of concept.
-
Rolf Bjaanes April 3rd, 2010 @ 06:30 PM
Could this be related to https://rails.lighthouseapp.com/projects/8994/tickets/3576-inflecti... ?
See the test in the patch.
-
Rolf Bjaanes April 3rd, 2010 @ 06:34 PM
Uhm, seems as this is regarding uncountables with two or more words in them, might be wrong.
-
Andrew White April 5th, 2010 @ 10:15 AM
Okay, I've managed to track down what's happening here. Basically autoload_module! in AS::Dependencies is creating a module dynamically because autoloadable_module? is returning true due to app/views being in the load_paths array.
More people would have hit this problem except for the fact that the app/models path is earlier in the load_paths array and controllers are normally plural and model names singular.
I'm assuming that app/views has been added to load_paths for a reason?
It's easy to reproduce this:
$ rails testapp ... $ cd testapp $ rails generate controller projects ... $ rails console >> Projects.class # Should raise NameError: uninitialized constant Projects => Module
-
José Valim April 5th, 2010 @ 10:56 AM
- State changed from needs-more-info to open
Right, thanks for finding out the reason Andrew! You've been doing an excellent work on other tickets as well. I'm on this one!
-
Repository April 5th, 2010 @ 11:33 AM
- State changed from open to resolved
(from [c140aca361506a3a759fbe03fad8adc748c807bb]) Remove app/views from the load paths [#4226 state:resolved] http://github.com/rails/rails/commit/c140aca361506a3a759fbe03fad8ad...
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to High
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
Referenced by
- 4226 Possible bug with uncountable inflections and namedspace routes? (from [c140aca361506a3a759fbe03fad8adc748c807bb]) Remove ...