Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
nested application ApplicationController get called intead of children::ApplicationController
2 Posts
nested application ApplicationController get called intead of children::ApplicationController

Assuming that all the routes and database.yml are configured properly the issue may be because of namespace error. Rails see the same name and is calling the teacher controller. So the best way to solve is get the nested application controller code in the single application controller and name the nested controller as something like Childrenteachers controller. Then use something like

class childrenteacher::ApplicationController < children::ActionController::Base

This will be neater and easy for rails to understand.

Easiest solution for this is to use gems to connect to different databases. Refer https://github.com/cherring/connection_ninja for more information. This can be done using this gem. I feel instead of trying as it is mentioned in question, one can use the gem (in the link) and try to use the data in show page. This gem is generally used to connect two databases from two different database servers inside single application.

I have two applications school and children. With children application nested in school application. Each of them have its own Database. But when i call the function show in app/controllers/children/teacher it's the function show in app/controllers/teacher which respond. It is calling the app/controllers/application_controller not app/controllers/children/application_controller... How can i fix it? I am using RoR 2.3. why class children::ApplicationController < children::ActionController::Base is not working(limiting the namespace)?

2 Posts
Login to add your message