Forum: Ruby on Rails Parent::Children controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Klaus Paiva (Guest)
on 2007-01-09 04:59
(Received via mailing list)
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

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

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!
Andrew S. (Guest)
on 2007-01-09 05:47
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
>
> Everything working till here. But I would like to display a blog
> overview here:
>
> 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?
Ross R. (Guest)
on 2007-01-09 08:57
(Received via mailing list)
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> 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
This topic is locked and can not be replied to.