# Unknown action - incorrect route

**URL:** <https://www.ruby-forum.com/t/unknown-action-incorrect-route/150533>\
**Category:** Rails\
**Created:** [October 9, 2008, 4:43pm UTC](https://www.ruby-forum.com/t/unknown-action-incorrect-route/150533 "2008-10-09T16:43:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [October 9, 2008, 4:43pm UTC](https://www.ruby-forum.com/t/unknown-action-incorrect-route/150533/1 "2008-10-09T16:43:24Z")

</div>

I have a form called edit.rhtml that lets you edit attributes of an  
Event object.  
In the file I have the following code:  
\<% form\_tag :action =\> ‘update’, :id =\> @event do %\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag\_or\_cancel ‘Save Changes’ %\>  
\<% end %\>

The ‘update’ method in the controller is called to update attributes in  
the database. I understand this is my action.  
But when I hit the “submit\_tag\_or\_cancel” to save the changes, I get  
routed to:

[http://localhost:3000/events/8](http://localhost:3000/events/8)

In the browser I get Unknown Action; No action responded to 8

but I want to get routed back to the list of events:

[http://localhost:3000/events](http://localhost:3000/events)

My routes.rb configuration is as follows:  
map.edit\_event ‘events/edit/:id’, :controller =\> ‘events’, :action =\>  
‘edit’

I’ve tried changing the \<% form\_tag code around without success. Thank  
you very much for your help!

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [October 9, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/unknown-action-incorrect-route/150533/2 "2008-10-09T17:28:14Z")

</div>

Jason L. wrote:

> But when I hit the “submit\_tag\_or\_cancel” to save the changes, I get  
> My routes.rb configuration is as follows:  
> map.edit\_event ‘events/edit/:id’, :controller =\> ‘events’, :action =\>  
> ‘edit’
> 
> ## I’ve tried changing the \<% form\_tag code around without success. Thank you very much for your help!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

It’s probably defaulting to the default route:

map.connect ‘:controller/:action/:id’

You’ll need to specify a route for the :update action, but I think  
you’re better off using RESTful routes instead:

map.resources :events

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [March 26, 2009, 7:13am UTC](https://www.ruby-forum.com/t/unknown-action-incorrect-route/150533/3 "2009-03-26T07:13:03Z")

</div>

> map.resources :events

OK. I’m still learning about RESTful. I’ll study up on that. Thank you!
