Controller/action not working in url

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
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.

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.

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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs