# Incorrect path generation if some controller actions are under path prefix: expected behavior or bu

**URL:** <https://www.ruby-forum.com/t/incorrect-path-generation-if-some-controller-actions-are-under-path-prefix-expected-behavior-or-bu/190556>\
**Category:** Rails\
**Created:** [June 22, 2010, 6:31pm UTC](https://www.ruby-forum.com/t/incorrect-path-generation-if-some-controller-actions-are-under-path-prefix-expected-behavior-or-bu/190556 "2010-06-22T18:31:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitalii\_Khustochka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b9e5f3/32.png) [@Vitalii\_Khustochka](https://www.ruby-forum.com/u/Vitalii_Khustochka)\
**Post date:** [June 22, 2010, 6:31pm UTC](https://www.ruby-forum.com/t/incorrect-path-generation-if-some-controller-actions-are-under-path-prefix-expected-behavior-or-bu/190556/1 "2010-06-22T18:31:54Z")

</div>

Imagine I have a simple scaffolded model Order, controller  
OrderControllers with all the default views etc.

Then I modify routes to have all actions except index and show be  
available under /admin subdirectory:

resources :orders, :only =\> [:index, :show]  
scope ‘/admin’ do  
resources :orders, :except =\> [:index, :show]  
end

And after that on my index and show pages the following helper

link\_to ‘Show’, @order  
or  
link\_to ‘Show’, order

generate links that look like: ‘[http://localhost:3000/admin/orders/1](http://localhost:3000/admin/orders/1)’  
which is obviously incorrect and leads to Routing Error.

I know how to work around this (I’m using link\_to ‘Show’, {action =\>  
‘show’, :id =\> @order}) just wondering this is expected behavior for  
some reason or a bug?

---

<div class="post-metadata">

**Author:** ![Vitalii\_Khustochka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b9e5f3/32.png) [@Vitalii\_Khustochka](https://www.ruby-forum.com/u/Vitalii_Khustochka)\
**Post date:** [June 22, 2010, 7:18pm UTC](https://www.ruby-forum.com/t/incorrect-path-generation-if-some-controller-actions-are-under-path-prefix-expected-behavior-or-bu/190556/2 "2010-06-22T19:18:09Z")

</div>

Oh, I found the reason.

When routes are defined and helpers are generated in the  
‘define\_hash\_access’ method, the hash access function is named the  
same for show and update actions: hash\_for\_order\_path. So the update  
action’s path helper overwrites the show’s one.

I still wonder if it is a bug or a feature…

I can assume it may not RESTful what I did - routing show and update  
to different URLs. Maybe according to REST is expected to be GET and  
PUT to the same url.

But if specifying {action =\> ‘show’, :id =\> @order} produces correct  
path, then it seems it is not prohibited to route show and update to  
different urls.

Vitalii
