Skip to content

Commit

Permalink
fix: controller shortcuts config bug
Browse files Browse the repository at this point in the history
Actions config was overriding shortcuts config due to blueprints being
attached too soon.
  • Loading branch information
particlebanana committed Jul 17, 2013
1 parent 4eb97a3 commit 7e1ac60
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/hooks/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,20 @@ module.exports = function(sails) {
*/

bindCRUDRoutes: function ( ) {
var self = this;

// Apply prefix config (but strip leading and trailing slash)
var blueprintsPrefix = sails.config.controllers.blueprints.prefix;

// For every controller, bind all of its actions as routes
_.each(sails.controllers, function (controller, controllerId) {

// Mix in middleware from blueprints
self.middleware[controllerId].find = Controller.find;
self.middleware[controllerId].create = Controller.create;
self.middleware[controllerId].update = Controller.update;
self.middleware[controllerId].destroy = Controller.destroy;

// TODO: support blueprint config on a per-controller basis
if (!util.isDictionary(controller)) {
return;
Expand Down Expand Up @@ -205,12 +213,6 @@ module.exports = function(sails) {
self.middleware[controllerId] = {};
}

// Mix in middleware from blueprints
self.middleware[controllerId].find = Controller.find;
self.middleware[controllerId].create = Controller.create;
self.middleware[controllerId].update = Controller.update;
self.middleware[controllerId].destroy = Controller.destroy;

// Mix in middleware from user controller
_.each(controller, function(action, actionId) {

Expand Down

0 comments on commit 7e1ac60

Please sign in to comment.