Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Ember.js with a simple Sinatra backend

There is a lot of documentation of how to structure and create Ember.js apps with Rails as a backend. Pupular solutions are to use gems as ember-rails and ember-source or the all in one ember-appkit-rails.

However i'm trying to create a simple Sinatra app that handle a JSON only backend with Ember.js as the frontend. The few resources that i found seems a little outdated, so i'm looking for simple way to do that.

So my question is:
How i integrate Ember.js with a simple Sinatra backend ??
Examples of how to do so will be appreciated.

like image 727
Javier Cadiz Avatar asked Mar 23 '14 08:03

Javier Cadiz


1 Answers

There is a very simple repo on Github, that could serve as a starting point for you. Just grab the code, start the sinatra app server, and point your Ember datasource to it, like this:

    App.MyRestAdapter = DS.RestAdapter.extend({
      host: 'http://localhost:3000',
      namespace: 'api'
    });

    App.store = DS.Store.create({
      adapter: 'MyApp.MyRestAdapter'
    });

You could also look into the source of Travis CI, as they use Sinatra (travis-api) and Ember.js (travis-web).

like image 108
scivi Avatar answered Oct 12 '22 22:10

scivi