hi, I''m new to rails, trying to setup a simple site, in my routes.rb I
have map.root :controller => ''site'' , and in my
app/controller I have
defined site_controller.rb with action index and about. When I start up
the server, I can see my index on localhost:3000 as the default index,
but when I try to access localhost:3000/about, it gives my a routing
error saying "No route matches "/about" with
{:method=>:get}".
Please help
Thank you
--
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.
Tony Yin wrote:> hi, I''m new to rails, trying to setup a simple site, in my routes.rb I > have map.root :controller => ''site'' , and in my app/controller I have > defined site_controller.rb with action index and about. When I start up > the server, I can see my index on localhost:3000 as the default index, > but when I try to access localhost:3000/about, it gives my a routing > error saying "No route matches "/about" with {:method=>:get}". > Please help > > Thank youTry this, map.resources :controller_name, :collection => { :method_name => :get } Thanks, Anubhaw -- 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.
Anubhaw Prakash wrote:> Tony Yin wrote: >> hi, I''m new to rails, trying to setup a simple site, in my routes.rb I >> have map.root :controller => ''site'' , and in my app/controller I have >> defined site_controller.rb with action index and about. When I start up >> the server, I can see my index on localhost:3000 as the default index, >> but when I try to access localhost:3000/about, it gives my a routing >> error saying "No route matches "/about" with {:method=>:get}". >> Please help >> >> Thank you > > > Try this, > > map.resources :controller_name, :collection => { :method_name => :get } > > Thanks, > Anubhawhi Anubhaw, thanks for the reply, but that did not work. When I put that in my routes.rb, I lost home index; but I can view index from localhost:3000/site. But when I try to view localhost:3000/about it gives me an error message Unknown action No action responded to show. Actions: about, help, and index So it appears something is not connecting, even though I specified the action name and the action is defined in my controller. -- 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.
Tony Yin wrote:> Anubhaw Prakash wrote:>> Try this, >> >> map.resources :controller_name, :collection => { :method_name => :get } >> >> Thanks, >> Anubhaw > > hi Anubhaw, thanks for the reply, but that did not work. When I put that > in > my routes.rb, I lost home index; but I can view index from > localhost:3000/site. But when I try to view localhost:3000/about it > gives me an error message Unknown action > > No action responded to show. Actions: about, help, and index > > So it appears something is not connecting, even though I specified the > action name and the action is defined in my controller.Hi Tony, Site is your controller name. If you need to access a method from controller, the url should be like this ''localhost:3000/site/about''. When you hit ''localhost:3000/site'' the actual url is ''localhost:3000/site/index''. So in link to you need to specify controller name and action name. If you need the url like localhost:3000/about, you need to specify following in route:- map.connect ''/about'', :controller => ''site'', :action => ''about''. Thanks, Anubhaw -- 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.