pauld
2010-Oct-02 21:09 UTC
Basic question on controller; "no route matches for hello/world"
Just starting out with RoR3, and have tried to render first page. Here is code for hello_controller.rb class HelloController < ApplicationController def world render :text => "<h1>Hello world!</h1>" end end Did not make any changes to the routes.rb file. When I went to http://localhost:3000/hello/world I got the following error: ActionController::RoutingError (No route matches "/hello/world"): Do I need to make changes to the routes.rb file? If so, what changes? Thank you. -- 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.
Rajinder Yadav
2010-Oct-02 21:51 UTC
Re: Basic question on controller; "no route matches for hello/world"
On 10-10-02 05:09 PM, pauld wrote:> Just starting out with RoR3, and have tried to render first page. > > Here is code for hello_controller.rb > > > class HelloController< ApplicationController > def world > render :text => "<h1>Hello world!</h1>" > end > end > > Did not make any changes to the routes.rb file. When I went to > http://localhost:3000/hello/world I got the following error: > > ActionController::RoutingError (No route matches "/hello/world"): > > Do I need to make changes to the routes.rb file? If so, what changes? > > Thank you. >first follow the MVC convention of writing correct rails code, put view code in the views. get out of the habit now to write view code in the controller, the controller should be kept lean and mean as possible try putting the following line in routes.rb get ''hello/world'' -- Kind Regards, Rajinder Yadav -- 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.
radhames brito
2010-Oct-02 22:41 UTC
Re: Basic question on controller; "no route matches for hello/world"
On Sat, Oct 2, 2010 at 5:09 PM, pauld <paul.denlinger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Just starting out with RoR3, and have tried to render first page. > > Here is code for hello_controller.rb > > > class HelloController < ApplicationController > def world > render :text => "<h1>Hello world!</h1>" > end > end > > Did not make any changes to the routes.rb file. When I went to > http://localhost:3000/hello/world I got the following error: > > ActionController::RoutingError (No route matches "/hello/world"): > > Do I need to make changes to the routes.rb file? If so, what changes? >you are trying yo use this ====> match '':controller(/:action(/:id(.:format)))'' read! # This is a legacy wild controller route that''s not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match '':controller(/:action(/:id(.:format)))'' you are trying to access an action like this hello/world =====> # match '':controller(/:action)'' with that line commented is not possible to access actions the old non restfull way. -- 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.
pauld
2010-Oct-02 23:34 UTC
Re: Basic question on controller; "no route matches for hello/world"
Thank you very much, got it to work. On Oct 2, 3:41 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Oct 2, 2010 at 5:09 PM, pauld <paul.denlin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Just starting out with RoR3, and have tried to render first page. > > > Here is code for hello_controller.rb > > > class HelloController < ApplicationController > > def world > > render :text => "<h1>Hello world!</h1>" > > end > > end > > > Did not make any changes to the routes.rb file. When I went to > >http://localhost:3000/hello/worldI got the following error: > > > ActionController::RoutingError (No route matches "/hello/world"): > > > Do I need to make changes to the routes.rb file? If so, what changes? > > you are trying yo use this ====> match > '':controller(/:action(/:id(.:format)))'' > > read! > > # This is a legacy wild controller route that''s not recommended for > RESTful applications. > # Note: This route will make all actions in every controller accessible > via GET requests. > # match '':controller(/:action(/:id(.:format)))'' > > you are trying to access an action like this > > hello/world =====> # match '':controller(/:action)'' > > with that line commented is not possible to access actions the old non > restfull way.-- 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.
Robert Pankowecki (rupert)
2010-Oct-03 08:53 UTC
Re: Basic question on controller; "no route matches for hello/world"
Read: http://railscasts.com/episodes/203-routing-in-rails-3 http://edgeguides.rubyonrails.org/routing.html + http://railscasts.com/episodes/231-routing-walkthrough http://railscasts.com/episodes/232-routing-walkthrough-part-2 Robert Pankowecki -- 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.