This project is archived and is in readonly mode.
Namespaced models: ActiveModel::Name uses ActiveSupport::Inflector incorrectly?
-
Andrew White
- State changed from new to wontfix
- Importance changed from to Low
You need to add seafood_fish to your uncountable inflections:
# config/initializers/inflections.rb ActiveSupport::Inflector.inflections do |inflect| inflect.uncountable %w( seafood_fish ) end -
der_flo
The problem is that methods like
polymorphic_urlinternally use the Inflector in the way I described, but the router handles it differently. I want to give an example:rvm 1.9.2 rails new testapp cd testapp rails generate scaffold Seafood::Fish name:string rails generate controller test indexconfig/routes.rb (generated):
...
namespace :seafood do resources :fish end ...</code>
app/controllers/test_controller.rb:
class TestController < ApplicationController
def index render :text => polymorphic_url(Seafood::Fish) end end</code>
See what
rake routesshows:seafood_fish_index GET /seafood/fish(.:format) {:action=>"index", :controller=>"seafood/fish"}
seafood_fish_index POST /seafood/fish(.:format) {:action=>"create", :controller=>"seafood/fish"} new_seafood_fish GET /seafood/fish/new(.:format) {:action=>"new", :controller=>"seafood/fish"} edit_seafood_fish GET /seafood/fish/:id/edit(.:format) {:action=>"edit", :controller=>"seafood/fish"} seafood_fish GET /seafood/fish/:id(.:format) {:action=>"show", :controller=>"seafood/fish"} seafood_fish PUT /seafood/fish/:id(.:format) {:action=>"update", :controller=>"seafood/fish"} seafood_fish DELETE /seafood/fish/:id(.:format) {:action=>"destroy", :controller=>"seafood/fish"}</code>
But calling our action
/test/indexgives us the following error:undefined methodseafood_fishes_url' for #<TestController:0x9100848></code> </pre>
Do you see the problem? Or is it an inconsistency?
Thanks again!