Build a Serverless Ruby App with Jets in 2 Minutes
Tags: aws, ruby, tutorial
Published: 2019-08-14 01:56:20

---
title: Build a Serverless Ruby App with Jets in 2 Minutes
published: true
description: A rapid introduction to generating a toy Jets application
tags: aws, open source, ruby, tutorial
cover_image: https://thepracticaldev.s3.amazonaws.com/i/d257luzlpjw1acfpfs4j.jpeg
series: Ruby on Jets
---
<sup>Cover Image: [Man Holding Ice Cream Cone Under Cloud](https://www.pexels.com/photo/man-holding-ice-cream-cone-under-cloud-1262302/) by [Rakicevic Nenad](https://www.pexels.com/@rakicevic-nenad-233369)</sup>

There are a number of tools out there for building "serverless" applications, that is applications in which the configuration of the server is someone else's problem. As the developer, you just write the business logic, the engineers at AWS, Netlify, or Google can worry about all that boring infrastructure stuff.

At least, that is the idea.

Today the most popular tool for building serverless applications is probably the Serverless framework. That's a great tool if you're looking to build your application with JavaScript.

However, it has recently become easier to write serverless applications in other languages too!

I'm particularly interested in building software in Ruby, so I am watching the [Jets](https://rubyonjets.com/) framework. About 98% of Jets is the work of a friend of mine named [Tung Nguyen](https://www.boltops.com/about) (he's great). 

Tung is an AWS expert with a love of Ruby. He chose to build Jets as an interface for building serverless applications powered by AWS with Ruby. It's pretty cool how much work it is able to do for you.

> If you want to know more about Tung, [he talked about his career on my podcast](https://www.devpath.fm/episodes/aws-consultant-and-open-source-engineer-tung-nguyen) 🎙

In this tutorial, I'm going to build the most basic app. Well, not quite "Hello, world!" but something pretty simple.

This tutorial assumes you've got [Ruby](https://www.ruby-lang.org/en/) and [Bundler](https://bundler.io/) installed.

This is a skin-deep exploration of the automation in Jets, and the finished product won't be anything to write home about, but it will give you an idea of how easily Jets can help you prototype with its Rails-like code generation.

The first step is easy. Install Jets:

```sh
gem install jets
```

Hopefully, you see `Successfully installed jets-2.0.4` or something similar in your terminal.

Now, we ask Jets to generate an application for us!

```sh
jets new example_app
```

This should spit out a directory with some boilerplate code.

```sh
cd example_app
ls -A
```

```
.babelrc         .git             .rspec           README.md        config           package.json
.env             .gitignore       Gemfile          Rakefile         config.ru        public
.env.development .jetskeep        Gemfile.lock     app              db               spec
.env.test        .postcssrc.yml   Procfile         bin              node_modules     yarn.lock
```

We can now ask Jets to generate some code for our application:

```sh
jets generate scaffold post title:string
```

You should see something like this:

```
INFO: You're missing AWS credentials. Only local services are currently available
      invoke  active_record
      create    db/migrate/20190814012442_create_posts.rb
      create    app/models/post.rb
      invoke  resource_route
       route    resources :posts
      invoke  scaffold_controller
      create    app/controllers/posts_controller.rb
      invoke    erb
      create      app/views/posts
      create      app/views/posts/index.html.erb
      create      app/views/posts/edit.html.erb
      create      app/views/posts/show.html.erb
      create      app/views/posts/new.html.erb
      create      app/views/posts/_form.html.erb
      invoke    helper
      create      app/helpers/posts_helper.rb
```

Don't worry too much about the AWS credentials, we won't be deploying this toy app to AWS (though if you care to do the AWS setup, it is entirely possible to deploy this app).

Now, we need to ask Jets to spin up a database for us:

```sh
jets db:create db:migrate
```

This should create a database for you and run the migrations that were generated by our scaffold.

At this point, if we start the server, we should be able to interact with the `posts` resource.

```sh
jets server
```

Navigate to `localhost:8888/posts` and you should be greeted by the following UI:

![A screenshot of the basic UI generated by Jets](https://thepracticaldev.s3.amazonaws.com/i/tskuai9dc4s8g6l6os6w.png)

By clicking the `New Post` link, you should be able to create a new `Post` resource.

At this point, you're able to perform basic CRUD actions on that resource:

![A screenshot of the UI that Jets built for the Post resource](https://thepracticaldev.s3.amazonaws.com/i/bqdfim6hapzu1mcu12bq.png)

That's all it takes to build a local Jets application. In a future tutorial, I'll explain how each Ruby file maps to an AWS feature and how to deploy the application to AWS for a truly serverless Ruby application.

In the meantime, check out the [project on GitHub](https://github.com/tongueroo/jets) and help Tung out with a few PRs. 🤠