Templating Options Building an API

I am asking for your opinion on what’s the best way to generate a rails API. I am following ThoughtBot’s iOS on Rails book and three possible templating options come to mind:

1. Use default rails template - rails new APIapp. This will generate a full ruby-on-rails app.
2. Use rails-api/rails-api gem - rails-api new APIapp. This will generate a lighter version of option 1.
3. Use thoughtbot/suspenders gem - suspenders APIapp. This will generate thoughtbot’s suggested ruby-on-rails app.

My opinion is to use option 2, while adding only the necessary gems as suggested in the book, and incorporating some of the best practises of option 3. Please advise.

The iOS on Rails book states:

We used Suspenders, a Rails 4 template with thoughtbot’s standard defaults, to start our project…While Suspenders is not required to follow along with this book, it does conveniently include all of the gems we will use to test-drive our API, including: Factory Girl, RSpec, and Shoulda Matchers.

P.S. I understand that there is no best approach.

1 Like

I ended up going with Option 2, seeing that it was the only way to achieve a light app. The only addition I made was to the app/controllers/application_controller.rb:

class ApplicationController < ActionController::API
  # required for jbuilder and rspec-rails gems
  include ActionController::ImplicitRender
  include ActionController::Helpers
  include ActionController::Caching
end

Cheers!