title: Use getJSON for Data in Ember.js
body: <p>First time using Ember. </p>
  
  <p>I've read everything I can and can use help building my understanding.</p>
  
  <p>I've been able to render the Ember template inside the rails template.</p>
  
  <p>Now I'm working on binding data using getJSON to the ember template, but I'm getting a few errors. <code>Uncaught TypeError: Cannot call method 'reopenClass' of undefined</code> <code>Error while loading route: TypeError {}</code></p>
  
  <p><strong>api/v1/newslinks_controller.rb</strong></p>
  
  <pre><code>class Api::V1::NewslinksController &lt; ApplicationController
    respond_to :json
  
    def index
      respond_with Newslink.all
    end
  
    def create
      respond_with Newslink.create(params[:newslink])
    end
  
    def update
      respond_with Newslink.update(params[:id], params[:newslink])
    end
  
    def destroy
      respond_with Newslink.destroy(params[:id])
    end
  end
  </code></pre>
  
  <p><strong>/api/v1/newslinks.json</strong></p>
  
  <pre><code>{"newslinks":[{"id":1,"title":"A Sample Post","navlink":"This will be a simple post record."}]}
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>    App = Ember.Application.create({
        LOG_TRANSITIONS: true,
        LOG_ACTIVE_GENERATION: true,
        LOG_VIEW_LOOKUPS: true,
        rootElement: '#ember',
        ready: function() {
          console.log('I am app');
        }
      });
  
      App.Router.map(function() {
          this.resource('newslinks', { path: '/' });
          console.log("I am router")
      });
  
      App.IndexRoute = Ember.Route.extend({
      });
  
      App.NewslinksRoute = Ember.Route.extend({
        model: function() {
          return App.Newslink.all();
        }
      });
  
      App.Newslink.reopenClass({
           all: function() {
             return $.getJSON("/api/v1.newslinks_controller.json").then(function(response) {
                        var newslinks = [];
  
                        response.newslinks.forEach(function(newslink) {
                    newslinks.push(App.Newslink.create(newslink));
                  }); 
                        return newslinks;
                });
           }
      });
  </code></pre>
  
  <p><strong>newslinks.handlebars</strong></p>
  
  <pre><code>&lt;div class="offset1"&gt;
    &lt;h1&gt;Newslinks&lt;/h1&gt;
  
    &lt;ul&gt;
      {{#each newslink in model}}
        &lt;li&gt;{{newslink.title}}&lt;/li&gt;
        &lt;li&gt;{{newslink.navlink}}&lt;/li&gt;
      {{else}}
        &lt;li&gt;There is no news.&lt;/li&gt;
      {{/each}}
    &lt;/ul&gt;
  
    {{outlet}}
  &lt;/div&gt;
  </code></pre>
  
  <p>Grateful for any assistance!</p>