Reputation: 259
I have two Devise models (Doctor and Patient) in my app. And i have two different sets of controllers for each one. At the moment i just prefixing each controller like this: PatientRegistrationsController, DoctorRegistrationsController etc.
But now i'm thinking about using namespaces for better app organization and structure. For example, Patient::RegistrationsController, Doctor::SessionsController.
Help me deciding which strategy i should use with my controllers - namespaces or prefixing names. Is where any gotchas with namespaces?
Upvotes: 1
Views: 549
Reputation: 11811
See http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
You can put the controllers in seperate folders and access them via a different route...
f.e..
namespace :doctor do
resources :data_entries
end
# => http://test.com/doctor/data_entries
# => controller is in app/doctor/data_entries_controller.rb
namespace :patient do
resources :data_entries
end
# => http://test.com/patient/data_entries
# => controller is in app/patient/data_entries_controller.rb
Upvotes: 1