diff --git a/app/assets/javascripts/admin/routes/admin-route-map.js.es6 b/app/assets/javascripts/admin/routes/admin-route-map.js.es6
index c5ce804ef..b71d9ce99 100644
--- a/app/assets/javascripts/admin/routes/admin-route-map.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-route-map.js.es6
@@ -1,5 +1,7 @@
-export default function() {
-  this.resource('admin', function() {
+export default {
+  resource: 'admin',
+
+  map: function() {
     this.route('dashboard', { path: '/' });
     this.resource('adminSiteSettings', { path: '/site_settings' }, function() {
       this.resource('adminSiteSettingsCategory', { path: 'category/:category_id'} );
@@ -60,6 +62,5 @@ export default function() {
     this.resource('adminBadges', { path: '/badges' }, function() {
       this.route('show', { path: '/:badge_id' });
     });
-
-  });
-}
+  }
+};
diff --git a/app/assets/javascripts/discourse/routes/discourse_route.js b/app/assets/javascripts/discourse/routes/discourse_route.js
index c3af37a09..75be93d63 100644
--- a/app/assets/javascripts/discourse/routes/discourse_route.js
+++ b/app/assets/javascripts/discourse/routes/discourse_route.js
@@ -89,23 +89,53 @@ Discourse.Route.reopenClass({
   },
 
   mapRoutes: function() {
+    var resources = {};
+
+    // If a module is defined as `route-map` in discourse or a plugin, its routes
+    // will be built automatically. You can supply a `resource` property to
+    // automatically put it in that resource, such as `admin`. That way plugins
+    // can define admin routes.
+    Ember.keys(requirejs._eak_seen).forEach(function(key) {
+      if (/route-map$/.test(key)) {
+        var module = require(key, null, null, true);
+        if (!module || !module.default) { throw new Error(key + ' must export a route map.'); }
+
+        var mapObj = module.default;
+        if (typeof mapObj === 'function') {
+          mapObj = { resource: 'root', map: mapObj };
+        }
+
+        if (!resources[mapObj.resource]) { resources[mapObj.resource] = []; }
+        resources[mapObj.resource].push(mapObj.map);
+      }
+    });
+
     Discourse.Router.map(function() {
       var router = this;
 
+      // Do the root resources first
+      if (resources.root) {
+        resources.root.forEach(function(m) {
+          m.call(router);
+        });
+        delete resources.root;
+      }
+
+      // Apply other resources next
+      Object.keys(resources).forEach(function(r) {
+        router.resource(r, function() {
+          var res = this;
+          resources[r].forEach(function(m) {
+            m.call(res);
+          });
+        });
+      });
+
       if (routeBuilder) {
         Ember.warn("The Discourse `routeBuilder` is deprecated. Export a `route-map` instead");
         routeBuilder.call(router);
       }
 
-      // If a module is defined as `route-map` in discourse or a plugin, its routes
-      // will be built automatically.
-      Ember.keys(requirejs._eak_seen).forEach(function(key) {
-        if (/route-map$/.test(key)) {
-          var module = require(key, null, null, true);
-          if (!module) { throw new Error(key + ' must export a map function.'); }
-          module.default.call(router);
-        }
-      });
 
       this.route('unknown', {path: '*path'});
     });
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb
index fe58ea5a0..fe99b6c9f 100644
--- a/lib/post_destroyer.rb
+++ b/lib/post_destroyer.rb
@@ -116,16 +116,15 @@ class PostDestroyer
     end
   end
 
-
   private
 
   def make_previous_post_the_last_one
     last_post = Post.where("topic_id = ? and id <> ?", @post.topic_id, @post.id).order('created_at desc').limit(1).first
     if last_post.present?
       @post.topic.update_attributes(
-          last_posted_at: last_post.created_at,
-          last_post_user_id: last_post.user_id,
-          highest_post_number: last_post.post_number
+        last_posted_at: last_post.created_at,
+        last_post_user_id: last_post.user_id,
+        highest_post_number: last_post.post_number
       )
     end
   end