Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move a group of controllers into a folder?

I have generated a group of scaffolds with edited code inside, but now I want to move these groups of controllers into a folder, let's say its name is admin. How do I do it?

I put Admin:: in the controller already, moved them into a folder already, but still there is an error.

like image 851
wizztjh Avatar asked Dec 10 '10 04:12

wizztjh


1 Answers

The piece I don't see above is what you're telling Rails' routing engine. This is probably what you're missing. If you're using Rails 3, I wrote an article about this:

Routing in Ruby on Rails 3

The section "Namespaced Routes" details how to setup the mapping in your routes file. Here's a code sample:

namespace :admin do
  resources :posts
end

You already have the other parts done. If you're using Rails 2.x, try this instead:

map.namespace(:admin) do |admin| 
  admin.resources :posts
end

I'll admit, I haven't tried this last snippet but it looks solid. I hope this helps!

like image 144
Jaime Bellmyer Avatar answered Nov 16 '22 01:11

Jaime Bellmyer