Hi all, I''m coming from the PHP world and I''m trying to learn Ruby and Rails. I''m having a problem where I keep getting the error "No route matches / home/view" even though I have it defined it. I''d appreciate any help on this. I''m using rails 3.0 and the setting for the environment is "development". # routes.rb Site::Application.routes.draw do get "home/index" root :to => "home#index" end # home_controller.rb class HomeController < ApplicationController def index @page_title = "Home" end def view @page_title = "View page" end end and I have two view files in app/views/home: index.html.erb view.html.erb -- 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.
can you reach to index action, or it is inaccessible too? On Aug 21, 11:58 am, DanielMedia <danielmedi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I''m coming from the PHP world and I''m trying to learn Ruby and Rails. > I''m having a problem where I keep getting the error "No route matches / > home/view" even though I have it defined it. I''d appreciate any help > on this. I''m using rails 3.0 and the setting for the environment is > "development". > > # routes.rb > Site::Application.routes.draw do > get "home/index" > root :to => "home#index" > end > > # home_controller.rb > class HomeController < ApplicationController > > def index > @page_title = "Home" > end > > def view > @page_title = "View page" > end > > end > > and I have two view files in app/views/home: > index.html.erb > view.html.erb-- 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.
I just defined a route: get "home/view" And it works... But I''m wondering if I HAVE to define a route for every page on my site. I was assuming if the controller/action existed it would just show it? -- 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 can see the index action if I go to / If I go to home/index, I cannot see the page unless I add get "home/ index" to my routes My routes file looks like this: # routes.rb Site::Application.routes.draw do root :to => "home#index" end # home_controller.rb class HomeController < ApplicationController def index @page_title = "Home" end def view @page_title = "View page" end end and I have two view files in app/views/home: index.html.erb view.html.erb -- 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.
On 21 August 2010 20:35, DanielMedia <danielmedia21-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just defined a route: > > get "home/view" > > And it works... But I''m wondering if I HAVE to define a route for > every page on my site. I was assuming if the controller/action existed > it would just show it?Have a look at the rails guide on routing ( at http://guides.rubyonrails.org/ ). All should then become clear (or at least less muddy). Check out the other guides also if you have not already done so. Colin -- 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.