Forum: Ruby on Rails Weird named routes&pluralization problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vinay (Guest)
on 2008-10-25 09:09
(Received via mailing list)
Hi all,
I have these models
Account has_many   :taxes
Tax        belongs_to  :account
And the tax resource is nested inside the account resource like so
map.resources :accounts do |account|
      account.resources :taxes, :name_prefix => nil
      ....#more resources here
end
Now when I rake the routes for Tax using rake routes|grep Tax in
Terminal, these are the named routes
taxes GET                        /accounts/:account_id/
taxes              {:controller=>"taxes", :action=>"index"}
formatted_taxes GET        /accounts/:account_id/taxes.:format
{:controller=>"taxes", :action=>"index"}
POST                              /accounts/:account_id/
taxes              {:controller=>"taxes", :action=>"create"}
POST                              /accounts/:account_id/
taxes.:format    {:controller=>"taxes", :action=>"create"}
new_taxis GET                 /accounts/:account_id/taxes/new
{:controller=>"taxes", :action=>"new"}
formatted_new_taxis GET  /accounts/:account_id/taxes/new.:format
{:controller=>"taxes", :action=>"new"}
edit_taxis GET                  /accounts/:account_id/taxes/:id/
edit            {:controller=>"taxes", :action=>"edit"}
formatted_edit_taxis GET   /accounts/:account_id/taxes/:id/
edit.:format {:controller=>"taxes", :action=>"edit"}
taxis GET                         /accounts/:account_id/
taxes/:id                   {:controller=>"taxes", :action=>"show"}
formatted_taxis GET         /accounts/:account_id/
taxes/:id.:format        {:controller=>"taxes", :action=>"show"}
PUT                                 /accounts/:account_id/
taxes/:id                   {:controller=>"taxes", :action=>"update"}
PUT                                 /accounts/:account_id/
taxes/:id.:format        {:controller=>"taxes", :action=>"update"}
DELETE                           /accounts/:account_id/
taxes/:id                   {:controller=>"taxes", :action=>"destroy"}
DELETE                           /accounts/:account_id/
taxes/:id.:format       {:controller=>"taxes", :action=>"destroy"}
You can see that the 'edit' and 'new' routes which are for a single
record of the Tax model are generated as 'new_taxis' and 'edit_taxis"
path for some reason instead of 'new_tax' and 'edit_tax' . I simply
used these routes instead but now im getting other errors. For eg.,
when i try to do current_account.taxes, i get the following error
"uninitialized constant Account::Taxis"
I cant make out what the problem is and how it came up. Hoping someone
can help me find a solution.
This topic is locked and can not be replied to.