Hi Community, I''m currently trying to create a blog software in rails, but I''ve got a problem: I generated scaffolding for my articles and only want administrators to write, edit or delete articles. So I wanted to move this parts to another, secured controller. The one controller to display articles is called articles :), the other is also called articles, but is located in a folder called "admin". The code looks like this: Admin::ArticlesController < ApplicationController. This works great. I can view the public area by http://localhost:3000/articles and the admin area by http://localhost:3000/admin/articles. But I''ve got problems with the routing: The named routes (?) generated by map.resources :articles (e.g. edit_article_path(article), new_article_path, and so on…) still point to the "public area", whereas the actions aren''t there. I think it''s pretty a newbie question, but how can I generate different routes so that these routes don''t point to the "public area". Thank you very much in advance Christoph --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
=== routes.rb map.namespace :admin do |admin| admin.resources :articles end then in your admin views you change your links like such: article => admin_article_url(article) edit_article_path(article) => edit_admin_article_url(article) the same methodology with paths. also check that the redirections from the controller are changed as well. Namely in the create, update and destoy. hope this helps On Jul 1, 3:32 pm, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Community, > I''m currently trying to create a blog software in rails, but I''ve got > a problem: > I generated scaffolding for my articles and only want administrators > to write, edit or delete articles. So I wanted to move this parts to > another, secured controller. The one controller to display articles is > called articles :), the other is also called articles, but is located > in a folder called "admin". The code looks like this: > Admin::ArticlesController < ApplicationController. This works great. I > can view the public area byhttp://localhost:3000/articlesand the > admin area byhttp://localhost:3000/admin/articles. But I''ve got > problems with the routing: The named routes (?) generated by > map.resources :articles (e.g. edit_article_path(article), > new_article_path, and so on…) still point to the "public area", > whereas the actions aren''t there. I think it''s pretty a newbie > question, but how can I generate different routes so that these routes > don''t point to the "public area". > > Thank you very much in advance > Christoph--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you very much for your quick and great help. That was exactly what I was looking for :) Christoph On 1 Jul., 16:45, "\"Wolas!\"" <jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> === routes.rb > > map.namespace :admin do |admin| > admin.resources :articles > end > > then in your admin views you change your links like such: > > article => admin_article_url(article) > edit_article_path(article) => edit_admin_article_url(article) > > the same methodology with paths. > > also check that the redirections from the controller are changed as > well. > Namely in the create, update and destoy. > > hope this helps > > On Jul 1, 3:32 pm, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Community, > > I''m currently trying to create a blog software in rails, but I''ve got > > a problem: > > I generated scaffolding for my articles and only want administrators > > to write, edit or delete articles. So I wanted to move this parts to > > another, secured controller. The one controller to display articles is > > called articles :), the other is also called articles, but is located > > in a folder called "admin". The code looks like this: > > Admin::ArticlesController < ApplicationController. This works great. I > > can view the public area byhttp://localhost:3000/articlesandthe > > admin area byhttp://localhost:3000/admin/articles. But I''ve got > > problems with the routing: The named routes (?) generated by > > map.resources :articles (e.g. edit_article_path(article), > > new_article_path, and so on…) still point to the "public area", > > whereas the actions aren''t there. I think it''s pretty a newbie > > question, but how can I generate different routes so that these routes > > don''t point to the "public area". > > > Thank you very much in advance > > Christoph--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Jul 1, 2008 at 7:43 PM, Christoph <chrisi.dibiasi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you very much for your quick and great help. That was exactly > what I was looking for :) > > ChristophAnd in your forms, instead of marking : <% form_for(@article) do |f| %> # form... <% end %> you can use <% form_for([ :admin, @article ]) do |f| %> # form... <% end %> to link to the correct action -- Gabriel Laskar <bibi.skuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 wrote a guide on doing exactly that: http://frozenplague.net/2008/03/16/administration-namespacing/ May also help out. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-02 12:49 UTC
Re: Scaffolding: Create, Edit, Destroy in admin area
Ryan, You need to check out your site. This is the second time I''ve clicked on a link you''ve promoted and there is simply a title with a blank page. Kathleen On Jul 1, 7:43 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I wrote a guide on doing exactly that:http://frozenplague.net/2008/03/16/administration-namespacing/ > > May also help out.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 1, 9:07 pm, "Gabriel Laskar" <bibi.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And in your forms, instead of marking : > > <% form_for(@article) do |f| %> > # form... > <% end %> > > you can use > > <% form_for([ :admin, @article ]) do |f| %> > # form... > <% end %> > > to link to the correct action >Completely forgot about that one! Completely right Gabriel. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Ryan, > You need to check out your site. This is the second time I''ve clicked > on a link you''ve promoted and there is simply a title with a blank > page.Works fine for me --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can only write this and still nothing else renaming or writing. map.namespace :admin do |admin| map.resources :article, :controller => ''admin/ article'', :path_prefix => ''admin'' end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---