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
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.