I have been searching a best practice to build the full stack application using Rails as backend API, and Ember for frontend framework. However, there are couple of things that I don’t know where to put in the application stack.
As I want to use Rails as backend API only, so I don’t know what I can do to authenticate user at this point. Whether I should handle it through Ember or what should I do?
Separate frontend and backend?
I saw some people using ember-rails gem to generate ember framework inside the Rails application. I don’t think this is a good practice in my case since I just want to use Rails as backend API only. Some people will use ember cli to setup the ember framework separate from Rails. I wonder if this is a good way to organize the code.
On squareup.com, look like they use Rails to handle their static pages. Is this a good idea to do so?
I’m working on a similar app right now.
A common way to authenticate an API is by authenticating via access token. A great basic resource for understanding that is Railscast #352. From there, you’ll need to be able to authenticate via an ember signup form. A good resource for this is Embercasts - Client-side authentication. Keep in mind both of these resources are most likely out of date and should be seen as a general overview only.
ember server --proxy http://localhost:3000. My app is pretty simple so I haven’t had too hard a time, but I could see testing becoming a concern with this method. Using Ember CLI, you can use mocks or fixtures to fake your API until it’s time to hook them both up, but the translation might not be one-to-one. I’d love to hear ideas from both camps on this.
I think the idea of serving static pages via Rails is a good approach—using Ember before it’s necessary seems pointless and probably adds complexity. Interested to hear others’ thoughts on this as well.
You can use the ember-cli-rails gem to allow you to use ember-cli inside of rails. So you get the best of both worlds.
Continuing this as more of a discussion, I’d be interested in hearing the direction some thoughbot developers are leaning towards. This might actually benefit a separate topic since front-end frameworks are becoming more robust / sprawling, and opinions are definitely divided, but…
I know formkeep was developed in Ember… did you guys take a separate codebase approach (a la EmberJS with a Separate Rails API), or was it built more as a “monolithic” app?