views:

28

answers:

2

My question is fairly simple, in an app I'm building, there is no need to show a user's account as a separate action from editing a user's account. That is, instead of

URL            | HTTP Verb  | Action
============================================
/account/new   | GET        | new
/account/edit  | GET        | edit
/account       | POST       | update
/account       | PUT        | create

I'm looking more for:

URL            | HTTP Verb  | Action
============================================
/account/new   | GET        | new
/account       | GET        | edit
/account       | PUT        | update
/account       | POST       | create

Right now, I have this in my routes file:

map.resource :account, :controller => "users", :except => [:show, :destroy]

which gets me very close, but how can I reroute the GET at the root level to give me the edit action instead of having to specify /edit in the URL?

A: 

Since your examples don't even mention IDs, I'd avoid mapping it as a resource altogether, and instead do map.connect and specify each route you want manually.

JRL
Well, I'm able to avoid IDs by doing `map.resource` instead of `map.resources`. I suppose I could switch to `map.connect`, but I guess I'm still curious if there's a way to do this my using `map.resource` ... even if the answer is "No, you can't do that. Stop trying." :)
jerhinesmith
A: 

Try:

map.connect '/account', :controller => "users", :action => "edit", :method => :get
map.resource :account, :controller => "users", :except => [:show, :destroy, :edit]
klew