Bruce Wilson
2011-Apr-07 17:51 UTC
Routing Error : No route matches "/" (for "Hello World!" action)
My routes.rb reads at the top: Hello::Application.routes.draw do match '':controller(/:action(/:id(.:format)))'' and then all the commented material it comes with and an "end" at the end of the file. But when I type http://localhost:3000 into my browser I get the following error message: Routing Error No route matches "/" I''m stumped. Bruce -- 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.
mainguy
2011-Apr-07 18:17 UTC
Re: Routing Error : No route matches "/" (for "Hello World!" action)
I don''t see that you''ve routed anything to the ''/'' path. Your route requires the controller to be in the path. First step would be to uncomment this # You can have the root of your site routed with "root" # just remember to delete public/index.html. # root :to => "welcome#index" replacing ''welcome'' with the controller you want / to route to and index.html with the action. Along those lines, usually there is a public/index.html that should be displayed. Do you have a file in public/html? -- 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.
Frederick Cheung
2011-Apr-07 19:06 UTC
Re: Routing Error : No route matches "/" (for "Hello World!" action)
On Apr 7, 6:51 pm, Bruce Wilson <bwilson...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> My routes.rb reads at the top: > > Hello::Application.routes.draw do > match '':controller(/:action(/:id(.:format)))'' > > and then all the commented material it comes with and an "end" at the > end of the file. > > But when I typehttp://localhost:3000into my browser I get the > following error message: > > Routing Error > No route matches "/" > > I''m stumped. >The above means that rails can only recognized paths that start with the name of a controller, optionally followed by an action and id. ''/'' clearly doesn''t fall into that pattern so you get a routing error. One way of specifying a default root is by saying root :to => ''pages#main'' which says that / should be routed to the main action in PagesController Fred> Bruce-- 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.
Bruce Wilson
2011-Apr-07 21:02 UTC
Re: Routing Error : No route matches "/" (for "Hello World!" action)
On Apr 7, 11:17 am, mainguy <mike.main...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t see that you''ve routed anything to the ''/'' path. > > Your route requires the controller to be in the path. > > First step would be to uncomment this > # You can have the root of your site routed with "root" > # just remember to delete public/index.html. > # root :to => "welcome#index" > > replacing ''welcome'' with the controller you want / to route to and > index.html with the action. > > Along those lines, usually there is a public/index.html that should > be displayed. > > Do you have a file in public/html?I''m following the instructions in Beginning Rails 3: $ rails generate controller salutation Then I added a Hello method to the controller. Then I created a hello.html.erb template in app/views/salutation. So the routes.rb file with this code: Hello::Application.routes.draw do match '':controller(/:action(/:id(.:format)))'' end is supposed to deliver the desired result of "Hello World!". But I went ahead and changed the routes.rb file to read: Hello::Application.routes.draw do root :to => "salutation#hello" That delivers the Hello World! in the browser, but along with the .erb code: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss \fcharset0 Arial;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 \par \tab \par \tab\tab Hello World! \par \tab \par \par } What to do? -- 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.
Frederick Cheung
2011-Apr-07 21:16 UTC
Re: Routing Error : No route matches "/" (for "Hello World!" action)
On Apr 7, 10:02 pm, Bruce Wilson <bwilson...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> On Apr 7, 11:17 am, mainguy <mike.main...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I don''t see that you''ve routed anything to the ''/'' path. > > > Your route requires the controller to be in the path. > > > First step would be to uncomment this > > # You can have the root of your site routed with "root" > > # just remember to delete public/index.html. > > # root :to => "welcome#index" > > > replacing ''welcome'' with the controller you want / to route to and > > index.html with the action. > > > Along those lines, usually there is a public/index.html that should > > be displayed. > > > Do you have a file in public/html? > > I''m following the instructions in Beginning Rails 3: > > $ rails generate controller salutation > Then I added a Hello method to the controller. > Then I created a hello.html.erb template in app/views/salutation. > > So the routes.rb file with this code: > > Hello::Application.routes.draw do > match '':controller(/:action(/:id(.:format)))'' > end > > is supposed to deliver the desired result of "Hello World!". > > But I went ahead and changed the routes.rb file to read: > > Hello::Application.routes.draw do > root :to => "salutation#hello" > > That delivers the Hello World! in the browser, but along with the .erb > code: > > {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss > \fcharset0 Arial;}} {\*\generator Msftedit > 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 \par \tab \par \tab\tab > Hello World! > \par \tab \par \par } >That looks like you edited your template with an editor that saved it as an rtf file rather than plain text. Fred> What to do?-- 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.
Bruce Wilson
2011-Apr-07 21:46 UTC
Re: Routing Error : No route matches "/" (for "Hello World!" action)
On Apr 7, 2:16 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 7, 10:02 pm, Bruce Wilson <bwilson...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > On Apr 7, 11:17 am, mainguy <mike.main...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I don''t see that you''ve routed anything to the ''/'' path. > > > > Your route requires the controller to be in the path. > > > > First step would be to uncomment this > > > # You can have the root of your site routed with "root" > > > # just remember to delete public/index.html. > > > # root :to => "welcome#index" > > > > replacing ''welcome'' with the controller you want / to route to and > > > index.html with the action. > > > > Along those lines, usually there is a public/index.html that should > > > be displayed. > > > > Do you have a file in public/html? > > > I''m following the instructions in Beginning Rails 3: > > > $ rails generate controller salutation > > Then I added a Hello method to the controller. > > Then I created a hello.html.erb template in app/views/salutation. > > > So the routes.rb file with this code: > > > Hello::Application.routes.draw do > > match '':controller(/:action(/:id(.:format)))'' > > end > > > is supposed to deliver the desired result of "Hello World!". > > > But I went ahead and changed the routes.rb file to read: > > > Hello::Application.routes.draw do > > root :to => "salutation#hello" > > > That delivers the Hello World! in the browser, but along with the .erb > > code: > > > {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss > > \fcharset0 Arial;}} {\*\generator Msftedit > > 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 \par \tab \par \tab\tab > > Hello World! > > \par \tab \par \par } > > What to do? > > That looks like you edited your template with an editor that saved it > as an rtf file rather than plain text. > > FredYou''re right! Much thanks to all of the above responders. But for the sake of learning, can anyone tell me why the Beginning Rails 3 code doesn''t work, and what exactly is it supposed to do?> > Hello::Application.routes.draw do > > match '':controller(/:action(/:id(.:format)))'' > > endBruce -- 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.