json - Problems renderingJSON posts with Ember frontend, Sinatra racked with Grape backend -


currently i'm having little trouble rendering json posts in ember, structure of app has config.ru file @ front, public folder ember content inside. app works, won't render posts, worked sinatra + ember since racked grape i've been having trouble. appreciated thanks.

config.ru:

require 'sinatra' require 'json' require 'grape' require 'sinatra/base'  $posts = {} $posts[123] = {:title => "rails omakase", :id => 123, :_id => 987, :author => "d2h", :publishedat => date.new(), :intro => "there lots of  la carte software environments in world. places         in order eat, must first on menu of options order   want.", :extended => "i want orm, want template language, , let's   finish off routing library. of course, you're going have know   want, , you'll have horizon expanded if order same thing,   there is. it's popular way of consuming software.\n\nrails not that. rails     omakase."   }  put '*/:id'  p "entering put /*/:id", params  raw = request.env["rack.input"].read  ## json data string  p "raw:", raw  $posts[params[:id].to_i] = json.parse(raw)['post'].merge({:id => params[:id].to_i})  p "\n\n+++++  $posts:", $posts  {:id => params[:i]}.to_json end   class api < grape::api  default_format :json  '/posts'   mount api::posts => '/posts'   data = {:posts => $posts.values}.to_json    return data  end end   class web < sinatra::base   '/posts'   p "entering get"   data = {:posts => $posts.values}.to_json   p "\n*** data:", data  data end  '/'  file.read(file.join('public', 'index.html')) end end  use rack::session::cookie run rack::cascade.new [api, web] 

app.js:

  app = ember.application.create({});    app.store = ds.store.extend({    revision: 12,    adapter: ds.restadapter.extend({    url: 'http://localhost:4567'   })  });  app.router.map(function() {   this.resource('about');   this.resource('posts', function() {   this.resource('post', { path: ':post_id' });  }); });   app.postsroute = ember.route.extend({   model: function() {   return app.post.find();  }   });  app.postcontroller = ember.objectcontroller.extend({  isediting: false,  edit: function() {  this.set('isediting', true); },  doneediting: function() {   this.set('isediting', false);   this.get('store').commit();  } });  var attr = ds.attr;  app.post = ds.model.extend({ title: attr('string'), author: attr('string'), intro: attr('string'), extended: attr('string'), publishedat: attr('date') });  var showdown = new showdown.converter();  ember.handlebars.registerboundhelper('markdown', function(input) {  return new handlebars.safestring(showdown.makehtml(input)); });  ember.handlebars.registerboundhelper('date', function(date) {  return moment(date).fromnow(); }); 

github repo : https://github.com/fatoblivion/blogger


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -