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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Paul, thanks for your help! I''ve found something useful on the book: Agile Web Development 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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I forgot to paste the book name. :D "Agile Web Development with Rails" Klaus Paiva wrote:> 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!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wouldn''t..... map.connect ''/admin'', :controller => ''admin/posts'', :action=>''index'' have the desired effect? On 1/9/07, Andrew Skegg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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? > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ross Riley www.sorrylies.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---