# Controller/action not working in url

**URL:** <https://www.ruby-forum.com/t/controller-action-not-working-in-url/137009>\
**Category:** Rails\
**Created:** [May 8, 2008, 7:41am UTC](https://www.ruby-forum.com/t/controller-action-not-working-in-url/137009 "2008-05-08T07:41:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@shikha](https://www.ruby-forum.com/u/shikha)\
**Post date:** [May 8, 2008, 7:41am UTC](https://www.ruby-forum.com/t/controller-action-not-working-in-url/137009/1 "2008-05-08T07:41:13Z")

</div>

Hey guys,

i am facing some problems in calling an action. see details:

in sale\_items controller, i have a function

def saleedit  
–code–  
render ( :action =\> ‘saleedit’)  
end

and i have a file in view/sale\_items/saleedit.html.erb.  
okay. now i have one more view view/sale\_items/new.html.erb. in this  
file i have a form like this:

\<% form\_tag url\_for(:action =\> ‘saleedit’) do %\>  
\<% end %\>

this is working fine with url →   
“[http://localhost:3000/sale\_items/saleedit](http://localhost:3000/sale_items/saleedit)”  
and goes to saleedit.html.erb on post. in saleedit.html.erb i have some  
links for delete in a table, means more than one deletes may be there.  
like this:

\<%= link\_to 'Delete', "delete/#{item.id}", :confirm =\> 'Are you sure?', :method =\> :delete %\>

so when i click on this link, delete function in sale\_items controller  
is called. i.e.

def delete

```
 --delete code--
 redirect_to ( :action => 'saleedit')

```

end

this is not working. it shows an error →   
ActiveRecord::RecordNotFound in Sale itemsController#show  
it is unable to search “saleedit” function and by default goes to show  
methos (default function-when no method is found it goes to show  
method). please help me out why it is unable to find the method.

in url it is taking “saleedit” as an id (parameter) rathe than an  
action.

Request

Parameters:

{“id”=\>“saleedit”}

in place of redirect\_to if i use “render (:action =\> ‘/saleedit’)”, it  
is working and control goes back to saleedit page, this is what I want.  
but the problem is with URL. in this case when we click on delete, the  
url becomes →

[http://localhost:3000/sale\_items/delete/4](http://localhost:3000/sale_items/delete/4).

so if more than one deletes are there, the next time when we click on  
next delete url becomes →   
[http://localhost:3000/sale\_items/delete/delete/1](http://localhost:3000/sale_items/delete/delete/1).

and shows a Routing Error

No route matches “/sale\_items/delete/delete/4” with {:method=\>:delete}

so i need a fast solution, i am in hurry. i ma unable to find why it is  
performing like this, how url will get changed and why controller is  
unable to find a method of its own.

your help is appreciated.  
thanks in advance!
