# Need help with routes

**URL:** <https://www.ruby-forum.com/t/need-help-with-routes/169568>\
**Category:** Rails\
**Created:** [June 5, 2009, 11:02am UTC](https://www.ruby-forum.com/t/need-help-with-routes/169568 "2009-06-05T11:02:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adsouzp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/df788c/32.png) [@adsouzp](https://www.ruby-forum.com/u/adsouzp)\
**Post date:** [June 5, 2009, 11:02am UTC](https://www.ruby-forum.com/t/need-help-with-routes/169568/1 "2009-06-05T11:02:50Z")

</div>

I will try to word this as simple as possible…

I made a scaffold called ‘cover’ then migrated the table.

Of course the index, show, edit, and new .html.erb files work correctly  
when they are called BUT, when I created a new .html.erb called ‘home’ I  
routed it as so:

map.connect ‘/covers/’, :controller=\>‘covers’, :action=\>‘home’

and added

def home  
end

I get the error “Couldn’t find Cover with ID=home”

I want that page to show content of the scaffold but before I add more  
to the controller I want to make the page route “url” work.

Is my route wrong? Do I need to add something to the controller?

I’m trying to keep the application in 1 folder and staying away from the  
has\_many code.

---

<div class="post-metadata">

**Author:** ![adsouzp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/df788c/32.png) [@adsouzp](https://www.ruby-forum.com/u/adsouzp)\
**Post date:** [June 5, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/need-help-with-routes/169568/2 "2009-06-05T12:12:51Z")

</div>

Hi, Aaron D.!

Looks like you use “[http://localhost:3000/covers/home](http://localhost:3000/covers/home)” query instead  
of “[http://localhost:3000/covers](http://localhost:3000/covers)” for access to home action in covers  
controller.  
But it really stange, how you add a specific route…

try to use

map.resources :covers, :collection =\> { :home =\> :get }

# then use home\_covers\_path

# it should generate ‘/covers/home’

or, if you want only rename index action

map.home ‘covers’, :controller =\> ‘covers’, :action =\> ‘index’

# then use home\_path

# it should generate ‘/covers’

you can find much more competent explanation in this screencast

> **[\#34 Named Routes - RailsCasts](http://railscasts.com/episodes/34-named-routes)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

---

<div class="post-metadata">

**Author:** ![adsouzp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/df788c/32.png) [@adsouzp](https://www.ruby-forum.com/u/adsouzp)\
**Post date:** [June 5, 2009, 8:01pm UTC](https://www.ruby-forum.com/t/need-help-with-routes/169568/3 "2009-06-05T20:01:30Z")

</div>

Thanks for the information. I was going off of what the book “Head  
First Rails” explains on routes.

Just to be clear… I’m assuming “script/generate home\_covers\_path” will  
make my specific path correct? I don’t have much time to try it now but  
I will tonight. I’ll also look at that railscast before posting anymore  
questions about routes. Thanks a whole lot!
