Abder-rahman Ali
2010-Jun-21 10:13 UTC
Unknown action No action responded to 2. Actions: show
I''m trying to create a simple RoR application that shows me the records inside my table, provided that it is an example I''m working on the "Head First Rails" book. When I try to retrieve the record I get the following message: "Unknown action No action responded to 2. Actions: show" Why am I having that? And, how can I fix this issue? Provided that: 1- I have inserted one record in the SQLite3 database in the table "ads". 2- route.rb ActionController::Routing::Routes.draw do |map| map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end 2- ads_controller.rb class AdsController < ApplicationController def show @ad = Ad.find(params[:id]) end end 3- show.html.erb <html> <head> <title><%= @ad.name %></title> </head> <body> <p> <b>Name: </b><%= @ad. name %> </p> <p> <b>Description:</b><%= @ad. description %> </p> <p> <b>Price: </b><%= @ad. price %> </p> <p> <b>Seller Id: </b><%= @ad. seller_id %> </p> <p> <b>Email: </b><%= @ad. email %> </p> <p> <img src="<%= @ad.img_url %>"/> </p> </body> </html> Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m trying to create a simple RoR application that shows me the records inside my table, provided that it is an example I''m working on the "Head First Rails" book. When I try to retrieve the record I get the following message: "Unknown action No action responded to 2. Actions: show" Why am I having that? And, how can I fix this issue? Provided that: 1- I have inserted one record in the SQLite3 database in the table "ads". 2- route.rb ActionController::Routing::Routes.draw do |map| map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end 3- ads_controller.rb class AdsController < ApplicationController def show @ad = Ad.find(params[:id]) end end 4- show.html.erb <html> <head> <title><%= @ad.name %></title> </head> <body> <p> <b>Name: </b><%= @ad. name %> </p> <p> <b>Description:</b><%= @ad. description %> </p> <p> <b>Price: </b><%= @ad. price %> </p> <p> <b>Seller Id: </b><%= @ad. seller_id %> </p> <p> <b>Email: </b><%= @ad. email %> </p> <p> <img src="<%= @ad.img_url %>"/> </p> </body> </html> Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
SWEngineer
2010-Jun-21 10:56 UTC
Re: Unknown action No action responded to 2. Actions: show
The issue was that I forgot to insert the colon before id -> :id map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' Thanks. On Jun 21, 5:13 am, Abder-rahman Ali <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to create a simple RoR application that shows me the records > inside my table, provided that it is an example I''m working on the "Head > First Rails" book. > > When I try to retrieve the record I get the following message: > > "Unknown action > > No action responded to 2. Actions: show" > > Why am I having that? And, how can I fix this issue? > > Provided that: > > 1- I have inserted one record in the SQLite3 database in the table > "ads". > 2- route.rb > > ActionController::Routing::Routes.draw do |map| > map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' > map.connect '':controller/:action/:id'' > map.connect '':controller/:action/:id.:format'' > end > > 2- ads_controller.rb > > class AdsController < ApplicationController > def show > @ad = Ad.find(params[:id]) > end > end > > 3- show.html.erb > > <html> > <head> > <title><%= @ad.name %></title> > </head> > <body> > <p> > <b>Name: </b><%= @ad. name %> > </p> > <p> > <b>Description:</b><%= @ad. description %> > </p> > <p> > <b>Price: </b><%= @ad. price %> > </p> > <p> > <b>Seller Id: </b><%= @ad. seller_id %> > </p> > <p> > <b>Email: </b><%= @ad. email %> > </p> > <p> > <img src="<%= @ad.img_url %>"/> > </p> > </body> > </html> > > Thanks. > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Abder-rahman Ali
2010-Jun-21 10:56 UTC
Re: Unknown action No action responded to 2. Actions: show
The issue was that I forgot to insert the colon before id -> :id map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ivan Nastyukhin
2010-Jun-21 11:20 UTC
Re: Unknown action No action responded to 2. Actions: show
in routes, delete all, and write ActionController::Routing::Routes.draw do |map| resources :ads end then in console write rake routes u will see all routes in your application than go to guides.rubyonrails.com and start read it _ thanks Ivan Nastyukhin dieinzige-BUHhN+a2lJ4@public.gmane.org On Jun 21, 2010, at 2:41 PM, SWEngineer wrote:> I''m trying to create a simple RoR application that shows me the > records > inside my table, provided that it is an example I''m working on the > "Head > First Rails" book. > > When I try to retrieve the record I get the following message: > > "Unknown action > > No action responded to 2. Actions: show" > > Why am I having that? And, how can I fix this issue? > > Provided that: > > 1- I have inserted one record in the SQLite3 database in the table > "ads". > > 2- route.rb > > ActionController::Routing::Routes.draw do |map| > map.connect ''/ads/id'', :controller=>''ads'', :action=>''show'' > map.connect '':controller/:action/:id'' > map.connect '':controller/:action/:id.:format'' > end > > 3- ads_controller.rb > > class AdsController < ApplicationController > def show > @ad = Ad.find(params[:id]) > end > end > > 4- show.html.erb > > <html> > <head> > <title><%= @ad.name %></title> > </head> > <body> > <p> > <b>Name: </b><%= @ad. name %> > </p> > <p> > <b>Description:</b><%= @ad. description %> > </p> > <p> > <b>Price: </b><%= @ad. price %> > </p> > <p> > <b>Seller Id: </b><%= @ad. seller_id %> > </p> > <p> > <b>Email: </b><%= @ad. email %> > </p> > <p> > <img src="<%= @ad.img_url %>"/> > </p> > </body> > </html> > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.