Edit
Since commit 8e57d61 you can do this to get blueprint
routes and functionality for nested controllers if your project has an AdminPage
model:
// api/controllers/admin/PageController.js module.exports = { _config: { model: 'adminpage' } }
or that:
// config/routes.js module.exports.routes = { 'admin/page': { model: 'adminpage' } }
Old answer
Your options
Defining explicit routes for your grouped controllers in config/routes.js
. See Scott Grace's answer for more details.
(If you are a little adventurous). Since I had the same requirement for my project, I created a Pull Request on sails, which allows you to override the model-controller association. You can install it through
npm install -g git://github.com/marionebl/sails.git
Assuming the api/models/Page.js
you need the api/controllers/admin/PageController.js
building methods you could do:
// api/controllers/admin/PageController.js ... module.exports = { _config: { model: 'page' } }
Explanation
While generating / creating grouped controllers like this is perfectly acceptable, you will not get the default routes that you would expect for controllers followed by models with the same identifier.
eg. api/controllers/UserController.js
and api/models/User.js
use the same user
identifier, so drawing routes are mounted if they are included in config/blueprints.js
.
In fact, at the moment it is not possible to correctly group models into subfolders. This means that you cannot create a model that matches the admin/page
ID of your controller api/controllers/admin/PageController.js
- drawing routes are not set for PageController
.
The source responsible for this behavior can be verified on Github .
source share