Rails-API - Part 1

  • jvancleef

Oops, a subscription is required to view this video. You can enroll now to watch, or try out all that Code School has to offer with a free two-day Hall Pass.


Justin Calleja said

Olivier, I think Matt was referring to the github repo for the app in the screen cast... not the one of rails-api - that's somewhat more popular and easy to find ;)

Of course, since it isn't in the resources, I'm guessing the app has no public repo... which is ok since it's easy to follow along from the vid. Still, why not?


Carlos Souza said

Levc, Rails::API > Grape for cases where you will be working with other people that might not be familiar with Grape. By using Rails::API, you are still getting all conventions and best-practices that a conventional Rails application offers out of the box.

Andrew said

I did not get the same output. I just got an array... I followed the video closely - it would help if there was an text writeup of the workflow.

levc said

Nice tutorial. In which cases would it be more suitable to use Rails::API than Grape?

Orlando Del Aguila said

@Theo, no, the difference is that rails-api is a much lighter stack. For example, it doesn't have all modules included in the ActionController class ( rails-api: https://github.com/rails-api/rails-api/blob/master/lib/rails-api/action_controller/api.rb#L125 / rails: https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/base.rb) and rails-api doesn't care about views or assets. Also, since you are not using a lot of middleware, it makes the app faster than a normal rails app.

Theo said

I don't understand what does the rails-api gem offer? Serving JSON from controllers is something that's already possible with rails.

As far as I could tell it's exactly the same workflow, just that the rails-api generator didn't include the extra files required by a classic rails app.

Is that the only difference?

Mark said

Great tutorial!

aldosolis@gmail.com said

Nice screencast! It would be great if there were a speed control.


Olivier Lacan said

Matt, the GitHub repo is linked to from the resources tab.

Matt Payne said

Please post the URLs to the github repo(s)

Jake Craige said

Excellent! There needs to be more information on this as I was having lots of trouble integrating my api with a sample angular app. Can't wait for part 2


With the rise of mobile applications, Angular.js and Ember.js support an increasing number of use cases where you only need Rails to serve an API and you can do away with the front-end. This is where the rails-api gem comes in.