Quantcast
Channel: Real Open
Viewing all articles
Browse latest Browse all 17

Ruby after Rails: Building a RESTful API with Grape & Napa - Pt. 1 (Introduction)

$
0
0

train crash

Out of the box, Ruby on Rails allows you to be very productive aided by great documentation and a significant library of Ruby & Rails gems maintained by a very active and open community. Since Rail's groundbreaking release in 2005, the framework's popularity has continued to grow in addition to it's underlying language, Ruby. However, a lot has changed since 2005 with mobile devices in everyone's pockets and increasingly powerful web browsers, leading to the rise of client side applications.

For some time, I've watched developers attempt to shoehorn single page applications like Backbone, Angular and Ember into a Rails app's app / assets / javascripts directory to be mangled by the (slow) asset pipeline as if it were a second-class citizen. This never felt natural and made the front end more difficult to work with as well as comprehend. In addition, if you just needed an API database application for say, an iPhone app - Rails seemed a bit bloated when all that was required is a database and RESTful endpoints.

the front-end has no business living in a Rails app at all - Michael Bleigh

On a recent client project, I used Angularjs to build a client-side application hosted statically on divshot.io. Not ready to give up on Ruby, I investigated several solutions like Sinatra, Padrino and rails-api for the server-side application. But these were either to small, to big, or included view-related logic that was simply not necessary. What I needed was a Ruby based web framework for building performant API database apps.

Grape is a REST-like API micro-framework based on Ruby. While it's been around since 2010 or so, it's is more of a library (think Sinatra) than a framework (Rails) meaning you have to build everything up folder-by-folder. Recently, a project came along called Napa by Bellycard that takes Grape and brings it together with things we all love from Rails like ActiveRecord, Rake and generators that make for a productive framework.

In this series, were going to build a RESTful API database application with Ruby & Napa loosely based on the Twitter clone ("microposts") application from the very popular Ruby on Rails Tutorial. If you'd like to follow-along, subscribe here and stay tuned for Pt. 2 where we're going to learn how to setup and bootstrap your first Napa application.


Viewing all articles
Browse latest Browse all 17

Latest Images

Trending Articles





Latest Images