Edit method and request.put? check

I am trying to use single method for Edit and Update…but doesn’t seem
to work.

Following is in my view…

<% form_for :project, @project, :html => {:method => :put}, :url =>
{:action => ‘edit’} do |f| %>
Name:
<%= f.text_field :name %>

Description:
<%= f.text_area :description, :rows => 5 %>

<%= f.submit “Submit” -%> <%= link_to ‘Cancel’, projects_path -%>
<% end -%>

and following is in my controller…

def edit
@project = Project.find(params[:id])

if request.put?
  respond_to do |format|
    if @project.update_attributes(params[:project])
      flash[:notice] = "Project updated successfully."
      format.html {redirect_to(projects_path)}
      format.xml {head :ok}
    end
  end
end

end

but when I press Submit, it says ‘nothing responded to 1 (id of
project).’

What could be wrong?

<% form_for :project, @project, :html => {:method => :put}, :url =>
You want something like
<% form_for :project, project_path(@project), …