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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With