Why does it route to "show" when excepting "new"?


I have the following in my routes:

resources :photos, :except => [:new, :edit]

When I get "/photos/new" instead of getting a no route error, it
routes to "show" and recognizes "new" as id.

Is that normal?


This is not a core ruby on rails question. This would be more suited for the Rubyonrails-talk mailing list.

I will still answer it though.

The reason for this is due to how it matches the route for the show action. The route is like this:


This means anything following /posts that doesn’t have a similar route defined for it will go to show, such as your /posts/new.

Just because you except the route doesn’t mean it will stop ALL routes from working that use that route. It means that it simply DOESN’T define the route for it. Anything else can have a route defined for that and it will still work.

Please be more careful about what lists you post to in the future.

Thanks for answer. Will be more careful on posting too.