Angular & Rails: A Perfect Match
The example application mentioned in this post can be found here: https://justcheckin.herokuapp.com
Ruby on Rails has been around for a good amount of time. It is a popular choice for many startups and side projects due to its keen ability to keep things simple. A simple app from development to deployment can be done in less than an hour if you know what you’re doing. If you need a technical solution done quickly and scalability is not your end concern (an entire conversation in itself), Ruby on Rails is a great choice.
Well Ruby on Rails comes with the ability to make your controller endpoints RESTful out-of-the-box. So making all of your endpoints available to pull records and post new records can be easily made accessible as an API. This will let you integrate with AngularJS very easily with their $http services. AngularJS has three methods to retrieve data from an endpoint: a Service, Factory, and Provider. These services can be injected into a given angular controller and allow you to interact with the endpoint, which then in turn can be bound to DOM objects on the page. Once you get it up and running, it is pretty seamless to interact with your API fluidly throughout your AngularJS application. So once you get your application up and running with Rails and AngularJS, iterating and adding new endpoints becomes very easy and allows you to quickly build out features and enhancements.
In hopes of showing off how easy both are to work with, I whipped up a simple application call CheckIn, which tracks basic data from the user’s browser as they checkin to the site. Then it shows you this data in a graphical manner as more checkins occur. It leverages AngularJS as the frontend and Ruby on Rails as the backend and only took a few hours to create and deploy. Over the next few weeks I will be following up this post with more posts around how to create an app like this.