Tutorial :Module name scopes in routing



Question:

I have an intranet application with several modules, I want them to separate when routing. For example:

 http://intranet/calendar/...   http://intranet/site_admin/...   http://intranet/tasks/...  

Each of module can have many or single controller. How to write such routes?


Solution:1

You can try using namespaces:

map.namespace :calendar do |calendar|    calendar.resources :first_controller    calendar.resources :second_controller  end  

And so on. Very often people put admin part of application in admin namespace (look here). Try google "rails namespace".


Solution:2

Also if you may want to upgrade to the latest version i.e Rails 2.3. And build those modules as separate 'Engines'. http://railscasts.com/episodes/149-rails-engines


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »