ActionController::UnknownAction (No action responded to 1):

Im new to ROR but i started prior to ROR 2.02. I spent a lot of time with the Depot app from "Agile web development 2nd" then upgraded to 2.02 and have learned alot getting the Depot app to work. the app works well exept for in the following condition:

-------From the edit view (app/views/admin)

<% form_tag :action => 'update',:id => @product do %>   <%= render :partial => 'form' %>   <%= submit_tag "Update" %>

-------should envoke the update action in the admin_controller

def update     @product = Product.find(params[:id])     if @product.update_attributes(params[:product])       flash[:notice] = 'Product was successfully updated.'       redirect_to :action => 'show', :id => @product     else       render :action => 'edit'     end   end

------UnknownAction (No action responded to 1): it looks like the :id is getting set in place of the action. Here is the log

Processing AdminController#1 (for at 2008-01-31 23:35:31) [POST]   Session ID: BAh7CDoMdXNlcl9pZGkGOgljYXJ0bzoJQ2FydAY6C0BpdGVtc1sAIgpmbGFz %0AaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpA %0AdXNlZHsA--a63cf499f342a8eddf7aff208c4e2824f8df4886   Parameters: {"commit"=>"Update", "product"=>{"image_url"=>"/images/ auto.jpg", "title"=>"Pragmatic Project Automation", "price"=>"29.9", "description"=>"Pragmatic Project Automation</em> shows you how to improve the consistency and repeatability of your project's procedures using automation to reduce risk and errors.\r\n\r\nSimply put, we're going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you'll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code."}, "action"=>"1", "controller"=>"admin"}   e[4;35;1mUser Load (0.000275)e[0m e[0mSELECT * FROM users WHERE (users."id" = 1) LIMIT 1e[0m

ActionController::UnknownAction (No action responded to 1):

You need to specify a :method => “put” into your form_tag.

It should also be form_for(@product) which should do all that url stuff for you.

could you give me an example of the :metohod => "put"

i tried to set it up as form_for(@product)


<h1>Editing product</h1>

<% form_for(@product) do |f|%>   <%= render :partial => 'form' %>   <%= f.submit "Update" %>

<% end %>

<%= link_to 'Show', :action => 'show', :id => @product %> | <%= link_to 'Back', :action => 'index' %>

NoMethodError in Admin#edit

Showing admin/edit.html.erb where line #11 raised:

undefined method `product_path' for #<ActionView::Base:0x22cd024> Extracted source (around line #11):

8: --> 9: <h1>Editing product</h1> 10: 11: <% form_for(@product) do |f|%> 12: <%= render :partial => 'form' %> 13: <%= f.submit "Update" %> 14: RAILS_ROOT: /Users/juano/code/DepotX

Application Trace | Framework Trace | Full Trace /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/polymorphic_routes.rb:27:in `send!' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/polymorphic_routes.rb:27:in `polymorphic_url' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/polymorphic_routes.rb:31:in `polymorphic_path' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ helpers/form_helper.rb:200:in `apply_form_for_options!' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ helpers/form_helper.rb:179:in `form_for' app/views/admin/edit.html.erb:11:in `_run_erb_47app47views47admin47edit46html46erb' Request


{"id"=>"1"} Show session dump



{"cookie"=>, "Cache-Control"=>"no-cache"}

To correct the error: undefined method `product_path' for #<ActionView::Base:0x22cd024>

Add this line to your routes.rb file: map.resources :products

(You can see this is in the example code in the book.)