# Parent::Children controller

**URL:** <https://www.ruby-forum.com/t/parent-children-controller/81432>\
**Category:** Rails\
**Created:** [January 9, 2007, 3:59am UTC](https://www.ruby-forum.com/t/parent-children-controller/81432 "2007-01-09T03:59:20Z")\
**Posts on this page:** 3\
**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:** [January 9, 2007, 3:59am UTC](https://www.ruby-forum.com/t/parent-children-controller/81432/1 "2007-01-09T03:59:20Z")

</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 9, 2007, 4:47am UTC](https://www.ruby-forum.com/t/parent-children-controller/81432/2 "2007-01-09T04:47:41Z")

</div>

Klaus Paiva wrote:

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

One way would be to specify it in the config/routes.rb as such:  
map.connect ‘/admin/posts/:action’, :controller =\> ‘posts’

Another might be to create a posts method in the admin controller and  
have it redirect to the posts controller (passing all the values  
across).

def posts  
redirect\_to :controller =\> ‘posts’, :action =\> params[:action]  
end

There is probably a better way to pass _all_ of the params across -  
anyone?

---

<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 9, 2007, 7:57am UTC](https://www.ruby-forum.com/t/parent-children-controller/81432/3 "2007-01-09T07:57:37Z")

</div>

wouldn’t…  
map.connect ‘/admin’, :controller =\> ‘admin/posts’, :action=\>‘index’

have the desired effect?

On 1/9/07, Andrew S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Everything working till here. But I would like to display a blog  
> > not the admin\_controller. Someone knows how can I do that?  
> > across).
> 
> >

–  
Ross R.  
[www.sorrylies.com](http://www.sorrylies.com)
