# Parent::Children controller

**URL:** <https://www.ruby-forum.com/t/parent-children-controller/80859>\
**Category:** Rails\
**Created:** [December 31, 2006, 10:31am UTC](https://www.ruby-forum.com/t/parent-children-controller/80859 "2006-12-31T10:31:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klaus\_Paiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/41988e/32.png) [@Klaus\_Paiva](https://www.ruby-forum.com/u/Klaus_Paiva)\
**Post date:** [December 31, 2006, 10:31am UTC](https://www.ruby-forum.com/t/parent-children-controller/80859/1 "2006-12-31T10:31:10Z")

</div>

Hello!

I’m creating a simple blog to test RoR. I’ve created an area to manage  
my blog posts by using the “generate controller Admin::Posts”. After  
creating my actions, I can acess them by using:

[http://localhost:3000/admin/posts/action\_here](http://localhost:3000/admin/posts/action_here)

Everything working till here. But I would like to display a blog  
overview here:

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

So I’ve created an admin controller: “generate controller Admin” and an  
“index” action. The new index action works but, the previous  
posts/action\_here not anymore.

I think that when I put /admin/posts on the URL and the controller admin  
exists, I need to tell that I want to use the posts\_controller, not the  
admin\_controller. Someone knows how can I do that?

Or if someone has a better idea to implement this I’ll be grateful!

Thanks for your attention!

---

<div class="post-metadata">

**Author:** ![Klaus\_Paiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/41988e/32.png) [@Klaus\_Paiva](https://www.ruby-forum.com/u/Klaus_Paiva)\
**Post date:** [January 1, 2007, 7:55pm UTC](https://www.ruby-forum.com/t/parent-children-controller/80859/2 "2007-01-01T19:55:55Z")

</div>

Klaus,

You are correct in thinking that the admin/admin.rb file is screwing  
things up. Nested controllers seem to work best when you split your  
controllers in groups like: admin/xxx and admin/yyy. Your controllers  
would then be under xxx or yyy but not split with some being directly  
under admin. You need no special routing configuration to accomodate  
this.

Perhaps your best solution right now is to just forget about nesting  
the controllers and have it all under admin until you can see how  
changing this structure would serve you better.

-Paul

---

<div class="post-metadata">

**Author:** ![Klaus\_Paiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/41988e/32.png) [@Klaus\_Paiva](https://www.ruby-forum.com/u/Klaus_Paiva)\
**Post date:** [January 3, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/parent-children-controller/80859/3 "2007-01-03T13:00:05Z")

</div>

Hi Paul,  
thanks for your help!

I’ve found something useful on the book: - It’s about the  
config/routes.rb. In this file I can define when to use the post  
controller by adding these lines:

# Admin::Posts

map.admin\_posts ‘admin/posts/:action/:id’,  
:controller =\> ‘admin/posts’,  
:requirements =\> {  
:id =\> /\d+/  
}

That’s it!

---

<div class="post-metadata">

**Author:** ![Klaus\_Paiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/41988e/32.png) [@Klaus\_Paiva](https://www.ruby-forum.com/u/Klaus_Paiva)\
**Post date:** [January 3, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/parent-children-controller/80859/4 "2007-01-03T13:00:31Z")

</div>

Hi Paul,  
thanks for your help!

I’ve found something useful on the book: Agile Web D. with  
Rails - It’s about the config/routes.rb. In this file I can define when  
to use the post controller by adding these lines:

# Admin::Posts

map.admin\_posts ‘admin/posts/:action/:id’,  
:controller =\> ‘admin/posts’,  
:requirements =\> {  
:id =\> /\d+/  
}

That’s it!

---

<div class="post-metadata">

**Author:** ![Klaus\_Paiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/41988e/32.png) [@Klaus\_Paiva](https://www.ruby-forum.com/u/Klaus_Paiva)\
**Post date:** [January 3, 2007, 1:04pm UTC](https://www.ruby-forum.com/t/parent-children-controller/80859/5 "2007-01-03T13:04:07Z")

</div>

I forgot to paste the book name. 😃

“Agile Web D. with Rails”
