mardi 5 septembre 2017

why is ember not loading the data from my controller

This is the first time I'm using Ember with Rails.

I have a controller rendering a json. I'm trying to render it with Ember and I keep getting a Completed 304 Not Modified. It seems like the Ember model is not reading the json from the controller. I can't figure out why. All help will be very appreciated.

Rails controller:

class DownloadersController < Admin::AdminController
  skip_before_filter :check_xhr

  def index
    google_list = DiscourseDownloadFromDrive::DriveDownloader.new(nil).json_list
    render json: google_list
  end
end

Rails routes:

  Discourse::Application.routes.append do
    get "/admin/plugins/discourse-sync-to-googledrive/downloader" => "downloaders#index"
    post "/admin/plugins/discourse-sync-to-googledrive/downloader", to: "downloaders#create", as: "download_file"
  end

Ember:

controllers/discourse-sync-to-googledrive-downloader.js.es6

export default Ember.Controller.extend({
  actions: {
    test() {
      alert('button clicked');
    }
  }
});

routes/discourse-sync-to-googledrive-downloader.js.es6

import { ajax } from 'discourse/lib/ajax';

export default Ember.Route.extend({
  model() {
    return ajax("/admin/plugins/discourse-sync-to-googledrive/downloader.json");
  }
});

templates/discourse-sync-to-google


  FILE!

  No files found


<button >test button</button>




Aucun commentaire:

Enregistrer un commentaire