# Trouble getting a top level page to Ember

**URL:** <https://meta.discourse.org/t/trouble-getting-a-top-level-page-to-ember/56007>\
**Category:** Development\
**Created:** [19 Enero, 2017 06:11 UTC](https://meta.discourse.org/t/trouble-getting-a-top-level-page-to-ember/56007 "2017-01-19T06:11:45Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)\
**Post date:** [19 Enero, 2017 06:11 UTC](https://meta.discourse.org/t/trouble-getting-a-top-level-page-to-ember/56007/1 "2017-01-19T06:11:45Z")

</div>

I’ve had fairly good experiences using plugin-outlets, but I wanted to improve my Discourse plugin dev chops.

So I decided I’d try to see if I could put together Ruby and Ember code by following this (that seems to be more about modifying Core files than plugins)

> [@Creating Routes in Discourse and Showing Data](https://meta.discourse.org/t/creating-routes-in-discourse-and-showing-data/48827):
>
> Over time Discourse has grown in complexity and it can be daunting for beginners to understand how data gets all the way from the back end Ruby on Rails application to the Ember.js application in front. This tutorial is meant to show the full lifecycle of a request in Discourse and explain the steps necessary if you want to build a new page with its own URL in our application. URLs First I always prefer to start thinking of features in terms of the URLs to access them. For example let’s say we…

I have a **plugin.rb**

```plaintext
# name: discourse-newpage
# about: learning exercise
# version: 0.1
# authors: Mittineague
# url: https://github.com/Mittineague/no-repo-for-this.git

enabled_site_setting :mitt_newpage_enabled

module ::DiscourseNewpage
  def self.plugin_name
    'discourse-newpage'.freeze
  end
end

after_initialize do

  module ::DiscourseNewpage
    class Engine < ::Rails::Engine
      engine_name "discourse-newpage"
      isolate_namespace DiscourseNewpage
    end
  end

  DiscourseNewpage::Engine.routes.draw do
    get '/newpage' => 'newpages#index'
    get '/newpage/:id' => 'newpages#show'
  end

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

  require_dependency 'application_controller'
  class DiscourseNewpage::NewpagesController < ::ApplicationController

    def index
      render json: { name: "donut", description: "delicious!" }
    rescue StandardError => e
      render_json_error e.message
# render text: 'Just sayin' # at newpage.json !?
# render inline: "<%= 'hello , ' * 3 + 'again' %>"	# at newpage.json !?
    end

    def show
      render json: { name: "cake", description: "moist!" }
    rescue StandardError => e
      render_json_error e.message
# render text: 'Just sayin' # at newpage.json !?
# render inline: "<%= 'hello , ' * 3 + 'again' %>"	# at newpage.json !?
    end
  end
end

```

By going to localhost:3000/newpage.json or localhost:3000/newpage/3.json I get the index and show (which oddly can also display “text” and “inline” by going to “json” when they are the “render”)

I have a **newpage-route-map.js.es6** file that currently is like

```plaintext
export default {
  map(function(){
    this.route('newpage', { path: '/index' });
    this.route('newpage/:id', { path: '/show' });
  });
}

```

and I have templates/_.hbs and routes/_.js.es6 files for “index” and “show”

After spending quite a bit of time the past few days trying countless variations of uppercase, lowercase, camelcase, slashes, periods, hyphens, different resources, different paths, etc. etc. etc. I have gone well beyond making educated best guesses and gone into throwing against the wall to see if it sticks territory.

No matter what I have tried doing, without the “.json” I invariably get the “OOPS!” page.

Maybe I’m missing the obvious?  
Maybe it is not possible at all?  
Maybe I need to extend a different controller?

Any and all suggestions are most welcome. TIA

---

_[View the full topic](https://meta.discourse.org/t/trouble-getting-a-top-level-page-to-ember/56007)._
