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: <br/> <%= f.text_field :name %> <br/> Description: <br/><%= f.text_area :description, :rows => 5 %> <br/> <%= 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?