# Rake routes & console showing one thing, app doing another

**URL:** <https://www.ruby-forum.com/t/rake-routes-console-showing-one-thing-app-doing-another/124470>\
**Category:** Rails\
**Created:** [December 29, 2007, 12:21am UTC](https://www.ruby-forum.com/t/rake-routes-console-showing-one-thing-app-doing-another/124470 "2007-12-29T00:21:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e480ec/32.png) [@mikel](https://www.ruby-forum.com/u/mikel)\
**Post date:** [December 29, 2007, 12:21am UTC](https://www.ruby-forum.com/t/rake-routes-console-showing-one-thing-app-doing-another/124470/1 "2007-12-29T00:21:45Z")

</div>

OK, I have a routing problem, that seems to be working in the console,  
and with rake routes but not in the app.

I have people that have nested tasks, like so:

* * *

# routes.rb

## map.resources :people do |person| person.resources :phone\_notes person.resources :documents person.resources :tasks, :member =\> {:complete =\> :put} end map.resources :tasks, :member =\> {:complete =\> :put}

And then if I go into irb and try to recognize and generate those  
routes, all is good:

* * *

> > rs = ActionController::Routing::Routes  
> > rs.recognize\_path(“/people/9/tasks/95/complete”, :method =\> :put)  
> > =\>  
> > {:action=\>“complete”, :person\_id=\>“9”, :controller=\>“tasks”, :id=\>“95”}  
> > rs.generate({:action=\>“update”, :person\_id=\>“9”,  
> > :controller=\>“tasks”, :id=\>“95”})  
> > =\> “/people/9/tasks/95/complete”

* * *

So that is all good.

Then rake routes gives me a list which also shows things are good:

* * *

## complete\_person\_task PUT /people/:person\_id/tasks/:id/complete {:controller =\> “tasks”, :action =\> “complete”}

But then in my people/show view I have:

* * *

## \<%= button\_to “Done”, :url =\> complete\_person\_task\_path(task), :method =\> :put -%\>

Which generates this URL:

* * *

## [http://127.0.0.1:3000/people/9?method=put&url=%2Fpeople%2F9%2Ftasks%2F95%2Fcomplete](http://127.0.0.1:3000/people/9?method=put&url=%2Fpeople%2F9%2Ftasks%2F95%2Fcomplete)

Which gives the following error:

* * *

## Unknown action No action responded to 9

So obviously the route is not tagging on the custom nested route I  
have made.

So I disabled the “default” routes at the bottom and then I get:

* * *

ActionController::MethodNotAllows

Only get, put, and delete requests are allowed

Request Parameters:

## {“url”=\>“/people/9/tasks/95/complete”, “method”=\>“put” }

Anyone got any ideas? I am sure it is something simple, but just  
tearing my hair out on this one.

Regards

Mikel

---

<div class="post-metadata">

**Author:** ![mikel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e480ec/32.png) [@mikel](https://www.ruby-forum.com/u/mikel)\
**Post date:** [December 31, 2007, 3:20am UTC](https://www.ruby-forum.com/t/rake-routes-console-showing-one-thing-app-doing-another/124470/2 "2007-12-31T03:20:17Z")

</div>

On Dec 29, 2007 10:21 AM, Mikel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## \<%= button\_to “Done”, :url =\> complete\_person\_task\_path(task), :method =\> :put -%\>
> 
> ## Unknown action No action responded to 9
> 
> Anyone got any ideas? I am sure it is something simple, but just  
> tearing my hair out on this one.

The solution was simple, button\_to doesn’t take :url =\> url, it just  
takes the "complete\_person\_task\_path(task) as the item.

so the button\_to line becomes.

\<%= button\_to “Done”, complete\_person\_task\_path(task), :method =\> :put  
%\>

Thanks to someone on IRC for finding this one.

Mikel
