Topic: Keeping getting 404 on ajax request

It is a simple todo example with the edit link trying to make a ajax request

<% for task in @tasks %>
  <tr>
    <td><%= task.name %></td>
    <td><%= task.points %></td>
    <td><%= link_to_remote "Edit", :url => edit_task_path(task), :method => :put %></td>
  </tr>
<% end %>
</table>

def edit
  @task = Task.find(params[:id])
   
  respond_to do |format|
    format.html {}
    format.js { }
  end
end

#This is the error that I get
<h1>Routing Error</h1>

<p><pre>no route found to match &quot;/tasks/1;edit&quot; with {:method=&gt;:put}</pre></p>


Is there anything special that I have to do when working with REST for ajax calls?

Thanks

Last edited by iso (2007-08-21 17:51:14)

Re: Keeping getting 404 on ajax request

in Rails REST, the edit action is a GET reqeuest, it only GETs the form for editing
the update action is a PUT request, however.
so try the remote link without the :method parameter

%= link_to_remote "Edit", :url => edit_task_path(task)%>

Last edited by Duplex (2007-08-21 17:54:42)

Re: Keeping getting 404 on ajax request

oops I am getting my verbs mixed up :0

Thanks for the help