Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most straight-forward way to use Ember.js for just one part of a Rails app?

I'd like to develop a Rails app with a full admin suite, authentication, authorization etc. that is pure Rails, but I would like there to be one part of the app that is 'real-time' and where the view is bound to the data, and I'd like to use Ember for this.

For example, I have a Company model, which has_many Parties, and Party has_many Guests. I would like a User to be able to log in, navigate to a Company page that they are authorized to access, and click a link to Company/:id/Party/:id/live, which would be a page featuring an Ember.js app that offers details of all of the Guests in the party. It would query the database every X seconds, and the Ember.js app would automatically reflect the updated data (e.g. one section of the page only shows Guests where Guest.status == in_attendance or something like this).

So my question is: Is there any standardized or proven way of incorporating Ember into just a portion of a Rails app in this manner?

Thanks!

like image 335
jackerman09 Avatar asked Dec 19 '25 03:12

jackerman09


1 Answers

To embed Ember application, you should do two things:

  1. Change root element from body to something else
  2. Disable URL management

Code samples:

App = Ember.Application.create({
  rootElement: '#app'
});

App.Router = Ember.Router.extend({
  location: 'none'
});

I took this information from Ember Guides: Embedding Applications

like image 132
denis.peplin Avatar answered Dec 21 '25 19:12

denis.peplin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!