I'm just starting a new project and I was interested in how to use admin 
areas with namespaces.
I read both articles above, and I think the real deal would be to use 2 
controllers, one being with 'admin' namespace.
On the views, I think the best way to keep DRY, would be to use probably 
some admin layout, and reuse partials from the public views. That's 
possible using the right arguments to render.
Let's say you've got a Product and User models. From within 
views/admin/products/index.html.erb one could use < render :partial => 
/products/index > or something like that.


Anyway, the reason for the post is, that I was reading the Rails Guides 
(rake doc:guides), and there is this interesting one about routing => 
"Rails routing from the outside in" which explains a whole lot of stuff.
And I came up with this solution (but didn't test it yet) for the unused 
actions on the public controllers and views.

map.with_options(:only => [:index, :show]) do |public|
  public.resources :products, :users
end

map.namespace(:admin) do |admin|
  admin.resources :products, :users
end

I think this can solve the issue, by using 2 controllers.
-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to