# Resourse route in namespace with prefix error

**URL:** <https://www.ruby-forum.com/t/resourse-route-in-namespace-with-prefix-error/140127>\
**Category:** Rails\
**Created:** [June 11, 2008, 3:47am UTC](https://www.ruby-forum.com/t/resourse-route-in-namespace-with-prefix-error/140127 "2008-06-11T03:47:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kidpollo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b782af/32.png) [@kidpollo](https://www.ruby-forum.com/u/kidpollo)\
**Post date:** [June 11, 2008, 3:47am UTC](https://www.ruby-forum.com/t/resourse-route-in-namespace-with-prefix-error/140127/1 "2008-06-11T03:47:27Z")

</div>

Ok so I have this route

map.namespace :trades do |trades|  
trades.resources :buys, :path\_prefix =\> ‘/trades/:contract\_id’  
end

I want the contract\_id variable to filter a list of buys

then I try to open this route [http://localhost:3000/trades/1/buys](http://localhost:3000/trades/1/buys)

I get a strange error:

ActionController::RoutingError in Trades/buys#index

Showing trades/buys/index.html.erb where line #12 raised:

trades\_buy\_url failed to generate from {:contract\_id=\>#\<Trades::Buy  
id: 5951, asset\_id: 309, type: “Buy”, contract\_id: 1, investor\_id: 1,  
date: “2001-09-30”, trade\_status\_id: 1, is\_future\_operation: false,  
quantity: #BigDecimal:7fb8004,‘0.2E2’,4(8), price: #\<BigDecimal:  
7fb7fb4,‘0.623E1’,8(12)\>, total: #\<BigDecimal:7fb7f64,‘0.1246E3’,  
8(12)\>, created\_at: “2008-06-10 22:49:31”, updated\_at: “2008-06-10  
22:49:31”\>, :action=\>“show”, :controller=\>“trades/buys”}, expected:  
{:action=\>“show”, :controller=\>“trades/buys”}, diff:  
{:contract\_id=\>#\<Trades::Buy id: 5951, asset\_id: 309, type: “Buy”,  
contract\_id: 1, investor\_id: 1, date: “2001-09-30”, trade\_status\_id:  
1, is\_future\_operation: false, quantity: #\<BigDecimal:7fb6a38,‘0.2E2’,  
4(8)\>, price: #BigDecimal:7fb69e8,‘0.623E1’,8(12), total:  
#BigDecimal:7fb6998,‘0.1246E3’,8(12), created\_at: “2008-06-10  
22:49:31”, updated\_at: “2008-06-10 22:49:31”\>}

Extracted source (around line #12):

12: \<%= link\_to ‘Show’, buy %\>

Is this a bug of some sort?

---

<div class="post-metadata">

**Author:** ![kidpollo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b782af/32.png) [@kidpollo](https://www.ruby-forum.com/u/kidpollo)\
**Post date:** [June 11, 2008, 5:01am UTC](https://www.ruby-forum.com/t/resourse-route-in-namespace-with-prefix-error/140127/2 "2008-06-11T05:01:43Z")

</div>

NOTE:  
if I dont use named routes I dont get this error for exampleif I use

\<%= link\_to 'Show', {:controller =\> "buys", :action =\> "show", :id =\> buy.id} %\>

There is no error
