Discourse.Route.buildRoutes is not a function

(Harold Sánchez Balaguera) #1

I’m trying to create a new route in discourse with ember, but when i try to visit the new page, appear that not exists, and in console log an error appears: Discourse.Route.buildRoutes is not a function

(Mittineague) #2

I struggled with this very problem a good amount yesterday trying to work up a plugin, except my error was

Routing Error
No route matches [GET] “/newpage”

I was trying Rails routing not Ember routing, but having no luck after many variations I was going to try Ember routing when Hypnos called.

I would most appreciate guidance as well.

(Harold Sánchez Balaguera) #3

I saw this message:

(Mittineague) #4

Maybe try ?


That looks to mean it isn’t a Rails or Ember routing, but both

(Harold Sánchez Balaguera) #5

I tested with the two and nothing.

This is my plugin:
I created the server route and nothing works.

(Robin Ward) #6

Can you post the code you’re using to add your route?

For reference, here is how discourse-tagging does it:

(Harold Sánchez Balaguera) #7

On JS:

On Plugin:

(Robin Ward) #8

Instead of calling Discourse.Router.map you should create a route-map in ES6 like the discourse-tagging plugin does above.

You should also do the same for your signup route class.

Going forward we will only support ES6 modules and not constants like Discourse.XYZ

Altering an Ember Route in a Plugin
(Harold Sánchez Balaguera) #9

Ok, I’ll try like discourse-tagging, i’ll write you how’s going on with creating routes

(Mittineague) #10

After much sighing, I have made some progress. :fireworks:

The discourse-tagging plugin is more complex than my current skill level so I “stripped out” everything that looked like I wouldn’t absolutely need it. (not the best practice, but …)

My primary goal as a starting point was simply to not get the Rails Error.

Success! Now I get a “doesn’t exist or is private” - but - the route does show up in the Ember Inspector.

I went deeper into Rails coding (eg. erb files) than I should have before I realized I needed to switch over to Ember coding to get the template to show.


after_initialize do

  module ::DiscourseNewpage
    class Engine < ::Rails::Engine
      engine_name "discourse_newpage"
      isolate_namespace DiscourseNewpage
  require_dependency "application_controller"
  class DiscourseNewpage::PagesController < ::ApplicationController
    def index
      render "pages/index.hbs" #The page you requested doesn't exist or is private.
  DiscourseNewpage::Engine.routes.draw do
    get '/' => 'pages#index'

  Discourse::Application.routes.append do
    mount ::DiscourseNewpage::Engine, at: "/page"



export default function() {
  this.resource("pages", function() {
    this.route('index', {path: 'index.hbs'});

(Harold Sánchez Balaguera) #11

I make a changes and works : GitHub - haroldSanchezb/discourse-route: Example for routing on discourse

(Robin Ward) #12

Did you forget to include the javascript?

(Harold Sánchez Balaguera) #13

with this form isn’t necessary create the route on client side


I also was able to get to this point, but I seem to have trouble getting passed that “… doesn’t exist or is private …” page. Could anyone shed light on what is wrong with how Mittingeague’s routes are set up?