# No route matches?

**URL:** <https://www.ruby-forum.com/t/no-route-matches/193661>\
**Category:** Rails\
**Created:** [August 21, 2010, 11:55am UTC](https://www.ruby-forum.com/t/no-route-matches/193661 "2010-08-21T11:55:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielMedia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@DanielMedia](https://www.ruby-forum.com/u/DanielMedia)\
**Post date:** [August 21, 2010, 11:55am UTC](https://www.ruby-forum.com/t/no-route-matches/193661/1 "2010-08-21T11:55:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DanielMedia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@DanielMedia](https://www.ruby-forum.com/u/DanielMedia)\
**Post date:** [August 21, 2010, 9:35pm UTC](https://www.ruby-forum.com/t/no-route-matches/193661/2 "2010-08-21T21:35:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DanielMedia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@DanielMedia](https://www.ruby-forum.com/u/DanielMedia)\
**Post date:** [August 21, 2010, 9:50pm UTC](https://www.ruby-forum.com/t/no-route-matches/193661/3 "2010-08-21T21:50:34Z")

</div>

can you reach to index action, or it is inaccessible too?

---

<div class="post-metadata">

**Author:** ![DanielMedia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@DanielMedia](https://www.ruby-forum.com/u/DanielMedia)\
**Post date:** [August 21, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/no-route-matches/193661/4 "2010-08-21T21:54:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DanielMedia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@DanielMedia](https://www.ruby-forum.com/u/DanielMedia)\
**Post date:** [August 21, 2010, 9:58pm UTC](https://www.ruby-forum.com/t/no-route-matches/193661/5 "2010-08-21T21:58:11Z")

</div>

On 21 August 2010 20:35, DanielMedia [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](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
