ember.js - Rerouting from existing Rails app to Ember -
intro
this first attempt @ ember (existing rails app) , there great resources out there on interweb, given have read them , still wanting more great check notes here.
i have new model: newslink have built api it: api/v1/newslinks.json
api works: http://localhost:3000/api/v1/newslinks.json
data
{"newslinks":[{"id":1,"title":"a sample post","navlink":"this simple post record."}]}
code
the issue ember seems letting route slip through hands (something did wrong in code below, i'm sure):
application.js
//= require jquery //= require jquery-ui //= require jquery_ujs //= require jquery-fileupload/basic //= require jquery-fileupload/vendor/tmpl //= require chosen-jquery //= require bootstrap //= require bootstrap-notify //= require jquery.limit-1.2.source //= require bootstrap-switch //= require handlebars //= require ember //= require ember-data //= require_self //= require app
app.js
app = ember.application.create({ log_transitions: true, ready: function() { console.log('app ready'); } }); app.router.map(function() { this.resource('newslinks', { path: '/' }); }); app.indexroute = ember.route.extend({ redirect: function() { this.transitionto('newslinks'); } }); app.newslinksroute = ember.route.extend({ model: function() { return app.newslink.find(); } }); ds.restadapter.reopen({ namespace: 'api/v1' }); app.store = ds.store.extend({ revision: 13 }); app.newslink = ds.model.extend({ name: ds.attr('string') });
application.handlebars
<!doctype html> <html> <head> <meta name="description" content="ember - latest" /> <meta charset=utf-8 /> <title>ember latest</title> <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script> <script src="http://builds.emberjs.com/ember-latest.js"></script> <script src="http://builds.emberjs.com/ember-data-latest.js"></script> </head> <body> <script type="text/x-handlebars"> <h2>here am</h2> </script> </body> </html>
routes.rb
app::application.routes.draw namespace :api namespace :v1 resources :newslinks end end
i'm not trying return data yet. want see route connect, i'm getting routing error. how make sure ember sees url "/newslinks"?
let me know if have suggestions. thanks!
random unrelated observation
ember.js seems lot reading borges' labyrinths, thing, , can tell better on subsequent readings until makes perfect sense.
i use chrome see url ember requesting. requesting '/newslinks' incorrect based on indicated url '/newslinks.json'
in case change route '/newslinks.json' more appropriate rest url format of '/newslinks'
Comments
Post a Comment