views:

25

answers:

1

I have the following route

map.resource :account, :controller => "users"
map.resources :users

and /account/new points to /users/new just fine.

However, if I add a new page, payment.html.erb, in /app/views/user, restart the server, and visit /account/payment, I get

No route matches "/account/payment" with {:method=>:get}

/users/payment does show the payment page, though.

Why is the route not working for /account/payment?

+2  A: 

Because you use RESTful routes you have to manually add them to your routing, like so:

map.resource :account, :controller => "users", :collection => { :payment => :get }

More info at the Rails Docs.

Janteh
With a singleton resource, you're not going to have the :collection option. You'd have to use :member.
Cratchitimo
Cool, thanks guys--that worked.
Chad Johnson