I previously discussed how I thought it best to integrate rails and AngularJS. I kicked off a process to build a standalone rails app and a standalone AngularJS app, with the two loosely coupled. This I thought had a lot of benefits in terms of giving access to the best of the tooling of each framework, the rails and rspec tooling at the rails end, the grunt and karma tooling at the Angular end. Having done that, I am now considering putting those two apps into the same directory for one key reason: my rails and my angular are in different git repositories, and it seems like I’m going to get the two out of synch.
Part of the answer is that if my app is loosely coupled that shouldn’t be a problem. But in basic application development terms it’s actually easier if they’re in the same directory. So, I’ve done a proof of concept of taking my existing tutorial and building instead in a single directory. It works fine, and the two toolsets don’t seem to argue with each other. So I think that can work, and it gives a single git repository. I have seen reports that this gives problems with Rails 4 (Rails 4 has a bin directory, as does ng-boilerplate), and I have dealt with this in the Rails 4 version of this tutorial.
This looks like it could also give some ancillary benefits. I haven’t really got any of the AngularJS templating working as yet, but if I were to do this within my overall rails framework, I can use rails to generate my AngularJS code through modifying the scaffold generators as I provided instructions for earlier. I think this has a lot of potential once I get the framework sorted to let me create a lifecycle similar to that we previously had with pure rails – being able to run a generator to create the database table, the rails controller and model, and create the angularJS views, along with all the associated unit tests. Sure, they all need tailoring, but the bulk of the code works right up front.
I’m still thinking on this, and I want to finish updates to the tutorial to integrate unit testing using Karma before I make a full decision. But, for now, and for those who are thinking about these things, I think this is a viable option.