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 127.0.0.1 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 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”}
[4;35;1mUser Load (0.000275) [0m [0mSELECT * FROM users WHERE
(users.“id” = 1) LIMIT 1 [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.

On Feb 1, 2008 3:42 PM, juano [email protected] wrote:

<%= submit_tag “Update” %>
end
%0AaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpA
[4;35;1mUser Load (0.000275) [0m [0mSELECT * FROM users WHERE
(users.“id” = 1) LIMIT 1 [0m

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


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

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

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

app/views/admin/edit.html.erb

Editing product

<% 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:

Editing product


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:inpolymorphic_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:inapply_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

Parameters:

{“id”=>“1”}
Show session dump

Response

Headers:

{“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.)