there is a diffrence somewhere between test and dev mode .. since custom inflected named routes generated by map.resources seem to work fine when running the actual app .. and when running controller tests
steps to reproduce:
- create a fresh app
- generate a controller (lets call it home)
- in environment add a custom inflection .. my problem case was "tax" => "taxes"
Inflector.inflections do |inflect|
inflect.irregular 'tax', 'taxes'
end
- create a new resource route for our non-existant tax model (doesn't seem to matter that it exists, so I'm ommiting creating the model for simplicity)
map.resources :taxes
- in the controller, create an action (lets call if foo), and lets try to generate a url to tax id: 1
def foo
render :text => tax_path(1)
end
- fill in a really basic test for the controller
def test_foo
get :foo
end
- adjust the test database to something that exists (or sqlite) just so it keeps some default test code happy that tries to use the db
ok .. so this is all the prep ..
now boot up the app, browse to /home/foo, you should be greeted with "/taxes/1" .. in other words it worked
now try to run the test ..
NoMethodError: undefined method `tax_path' for #<HomeController:0x221075c>
{rails_root}/config/../app/controllers/home_controller.rb:4:in `foo'
now some after checks
in ./script/console .. running "taxes".singularize yields "taxis" (without the custom inflection) .. (thats why I have the custom inflection) .. anyways .. going into the controller .. and changing "tax_path" to "taxis_path" .. makes it work in testing just fine (but it now crashes in dev)