# Routing problem with beginner tutorial app

**URL:** <https://www.ruby-forum.com/t/routing-problem-with-beginner-tutorial-app/188328>\
**Category:** Rails\
**Created:** [May 10, 2010, 10:56am UTC](https://www.ruby-forum.com/t/routing-problem-with-beginner-tutorial-app/188328 "2010-05-10T10:56:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@mattn](https://www.ruby-forum.com/u/mattn)\
**Post date:** [May 10, 2010, 10:56am UTC](https://www.ruby-forum.com/t/routing-problem-with-beginner-tutorial-app/188328/1 "2010-05-10T10:56:36Z")

</div>

I’m just getting started with Rails 2. Plus, it’s been a while since I  
played with Rails at all. So to explore, I whipped out an old Rails  
tutorial (from an O’Reilly book) and started going through it, to  
refresh my memory. This is just a simple “Hello world” experiment.

I created my rails app, cd’d into it, started the server, and created  
a simple controller:

script/generate controller greeting

So I tried to talk my controller in the browser:

[http://localhost:3000/greeting](http://localhost:3000/greeting)

And I got a routing error, “no route matches … with method get”.

I found this a bit hard to understand, because routes.db has the  
default routes, so my controller name should work from a GET request.  
But, nothing daunted, I added some overkill routing at the top of  
routes.db:

map.resources :greeting

Now [http://localhost:3000/greeting](http://localhost:3000/greeting) was routed properly; of course  
there was no index action but now at least I got the expected error  
message telling me so, I wrote an index method, and all was well;  
hello, world.

But here’s the weird part. I then _deleted_ the map.resources line  
from routes.db, and my app nevertheless continued working. I can rake  
routes and sure enough only the default routes are in force. So it  
looks like maybe this a bug in Rails, where it takes some manual  
jiggering to get the default routes operating properly? Anyway I  
figure this must be well known, so maybe someone could just explain it  
to me? No big deal, but I like to understand what’s going on, if  
possible - thx - m.

---

<div class="post-metadata">

**Author:** ![mattn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@mattn](https://www.ruby-forum.com/u/mattn)\
**Post date:** [May 10, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/routing-problem-with-beginner-tutorial-app/188328/2 "2010-05-10T12:04:31Z")

</div>

Get a habit to restart your development server after each change in  
routes.rb. And in models. Actually, I’m restarting the server a lot  
more times, than I probably should. But it’s better than fight with  
silly bugs which are not even exist.

---

<div class="post-metadata">

**Author:** ![mattn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@mattn](https://www.ruby-forum.com/u/mattn)\
**Post date:** [May 10, 2010, 7:05pm UTC](https://www.ruby-forum.com/t/routing-problem-with-beginner-tutorial-app/188328/3 "2010-05-10T19:05:32Z")

</div>

mattn wrote:

> I’m just getting started with Rails 2. Plus, it’s been a while since I  
> played with Rails at all. So to explore, I whipped out an old Rails  
> tutorial (from an O’Reilly book) and started going through it, to  
> refresh my memory.

Do not use old Rails tutorials with new versions of Rails.

Do not use old versions of Rails for new projects…

[…]

> But here’s the weird part. I then _deleted_ the map.resources line  
> from routes.db, and my app nevertheless continued working.

If you are using a version of Rails before 2.3, you need to restart the  
server for routing changes to take effect.

> I can rake  
> routes and sure enough only the default routes are in force.

Right, because rake loads a new instance of the Rails environment, and  
so it picks up the changes in the routes file.

> So it  
> looks like maybe this a bug in Rails, where it takes some manual  
> jiggering to get the default routes operating properly? Anyway I  
> figure this must be well known, so maybe someone could just explain it  
> to me? No big deal, but I like to understand what’s going on, if  
> possible - thx - m.

No bug. No manual jiggering. Your routes file just got out of sync  
with what the server already had in memory.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
