Reputation: 2209
I'm working on a project where we decided to use Angular and Rails for front-end and back-end. I know Angular and the back-end guys know Rails, we don't want to mix this together. There are a lot of tutorials like this on how to set up this as a single page app, I don't want this.
Upvotes: 0
Views: 230
Reputation: 8898
Actually I'm currently working on a project that uses both angular and rails. The following things are what I did and may help you.
For the back end I use of course Rails.
For the front end, I use Middleman since I am a ruby guy :P
Another reason for choosing middleman is that it has environments just like rails.
But you or your team can also choose bower or browserify or whatever that generates STATIC assests.
P.S. I tried RequireJS but decided not to use it because of its complicated boilerplate code.
Both the back end and the front end speak JSON (except for file uploading and downloading), so this is an obvious choice.
Note that Rails application should not send redirects, nor should it render HTML.
For the front end, ngResource is, well, not bad for consuming JSON responses, but sometimes you need to wrap it in your own services (I made my own resources
factory based on $resource
)
Of course you can use traditional cookie based authentication.
If you decides providing OAuth2, then ng-token-auth is a default consumer for Devise token auth. Note that ng-token-auth does not work so well with angular-file-upload.
Since the front end and the back end are 2 separated projects, they can also be deployed to different domains. In this case, implementing cross-origin resource sharing (CORS) is a must. Rack CORS can help you with CORS, but you can also implement it on the reverse proxy / load balancer layer and choose not to use Rack CORS.
Upvotes: 1
Reputation: 6078
Things that probably could help you with frontend part:
Upvotes: 1