Angularjs and rails: looking at integration

I’m looking to learn angularjs, based on the recommendation of an acquaintance.  I’ve read a fair bit about it, particularly from the angularjs home page.  It looks like a very powerful way to build a single-page web app, and has a bunch of benefits.  It also seems to have impenetrable documentation, and to be a little immature still.  Finally, the integration with rails is less than clear.

So, a challenge then.  Over the next wee while, I’ll be spending some of my free time trying to make something sensible out of this.  The first decision I’m making is how I’m going to tie rails and angularjs together, at least for the sample application.

I’ve looked backwards and forwards, and my conclusion is to entirely separate the two.  I’m going to have a rails application that purely serves up json, and offers no html client.  And then I’m going to have a standalone angular application that uses that rails app as a backend.

My logic here has a few parts:

  1. Both angular and rails  have scaffold generators, test frameworks etc.  These frameworks don’t look like they’re going to play together all that well in a single directory structure – they look like I’ll end up with lots of conflicts
  2. All the recommendations are to test your angular app using stubs in the first instance, then integration test it with your server.  Separating the two seems to have more potential for doing that
  3. Angular seems to push mostly static content to the client – it’s a set of javascript files and template html, everything that is dynamic comes from the server.  Therefore, it makes no sense to serve this with rails, it needs to be served directly from the web server.  So long-term they’re not going to live in the same directory structure anyway (arguably we can do this from the rails public directory, but there seems no reason to do so)
  4. The main downside I can see is the way coffeescript and minification work in rails looks cleaner – there could be some benefit there.  But I’m just going to live with that downside until I work out whether it’s even a downside at all.  I might bite the bullet and right in native javascript instead of coffee, notwithstanding that I dislike javascript intensely.

So, that’s my aim.  We’ll see how we go.


7 thoughts on “Angularjs and rails: looking at integration

  1. Pingback: Rails app for Angularjs, building the rails league application: part 1 | technpol

  2. Pingback: CRUD application with AngularJS, Rails, twitter-bootstrap and ng-boilerplate: part 2 boilerplate served by rails | technpol

  3. Pingback: CRUD application with AngularJS, Rails, twitter-bootstrap and ng-boilerplate: part 3 List | technpol

  4. Pingback: CRUD application with AngularJS, Rails, twitter-bootstrap and ng-boilerplate: part 5 New and Delete | technpol

  5. Pingback: AngularJS and Rails: Tutorial Index | technpol

  6. Pingback: AngularJS and Rails – shared directory or not | technpol

  7. Pingback: AngularJS and Rails CRUD application using ng-boilerplate and twitter bootstrap | Gatelockservice

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s