Base Rails application for REST API
Ruby HTML Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Skeleton for new Rails 4 application for REST API

Code Climate Build Status

This simple application includes ruby/rails technology which we use at FlatStack for new REST API projects.

Application currently based on Rails 4 stable branch and Ruby 2.3.6


Status of the API could be checked at http://localhost:5000/docs

What's included

Application gems:

Development gems

  • Foreman for managing development stack with Procfile
  • Letter Opener for preview mail in the browser instead of sending
  • Mail Safe keep ActionMailer emails from escaping into the wild during development
  • Bullet gem to kill N+1 queries and unused eager loading
  • Rails Best Practices code metric tool
  • Brakeman static analysis security vulnerability scanner
  • Bundler Audit Patch-level verification for Gems
  • Spring for fast Rails actions via pre-loading

Testing gems


  • 01_config.rb - shortcut for getting application config with app_config
  • mailer.rb - setup default hosts for mailer from configuration
  • requires.rb - automatically requires everything in lib/ & lib/extensions
  • rack_cors.rb - setup whitelist of domains to allow cross-origin resource sharing


  • bin/setup - setup required gems and migrate db if needed
  • bin/quality - runs rubocop, brakeman, rails_best_practices and bundle-audit for the app
  • bin/ci - should be used in the CI or locally
  • bin/server - to run server locally



Use that serializer if you want to add meta with pagination info on response

def index
    serializer: PaginatedArraySerializer

The above usage of PaginatedArraySerializer will produce the following:

  "meta": {
    "pagination": {
  "posts": [
    { "title": "Post 1", "body": "Hello!" },
    { "title": "Post 2", "body": "Goodbye!" }

Quick start

Clone application as new project with original repository named "rails-base-api"

git clone git:// --origin rails-base-api [MY-NEW-PROJECT]

Create your new repo on GitHub and push master into it. Make sure master branch is tracking origin repo.

git remote add origin[MY-GITHUB-ACCOUNT]/[MY-NEW-PROJECT].git
git push -u origin master

Run setup script


Make sure all test are green


Run app


Do not forget to update this file!

mv doc/
# update
git commit -am "Update"

Restrict access to documentation

You can enable restrict access to documentation by adding APITOME_USER and APITOME_PASSWORD environment variables. Can be useful on staging environment.


Please check how to build API endpoints and test them properly in the examples branch