Rails route to only index

Butter Beer picture Butter Beer · Dec 18, 2012 · Viewed 31.8k times · Source

This might be a simple routing question in Rails but I have searched around and received answers for Rails 2 rather than Rails 3.

I generated a scaffold and the

resources :users 

which includes new, edit, show are routed together with the index.

I only want to route to the index and remove the new, edit, show etc. I have already removed the html.erb files but they are still being routed.

Any advice on what I should do to remove the other routes would be appreciated.

Answer

Rodrigo picture Rodrigo · Dec 18, 2012

Use the only option:

resources :users, only: [:index]

Reference