Andy from Webcrunch

Subscribe for email updates:

Portrait of Andy Leverenz
Andy Leverenz

April 2, 2018

Last updated November 5, 2023

Let's Build: With Ruby on Rails - Job Board with Payments

Welcome to what I'll be calling my tenth installment to my Let's Build: With Ruby on Rails series. In this build, I'll cover how to build a filterable job board with payments using Stripe as a payment gateway to post new jobs.

More about the app

The basis of the application is a job board where anyone looking to get hired can come and apply for positions. If you are a user or company looking to post a job you can sign up for an account and do so for a fee. We use a combination of the Stripe API and the Stripe Ruby Gem to initialize a charge when a job gets posted.

If there are errors along the way the form will offer error feedback for both the Rails-based form and the Stripe based form.

Download the source code

Stripe Integration

Stripe has a variety of solutions when it comes to accepting payments securely. There's really no wrong way to do so but some applications may favor alternative approaches. In our case, I opted for Stripe Elements which is a drop-in replacement that allows you to display a form for the credit card of which you can manipulate at will.

Styling it or triggering something to happen upon user input is completely up to you. If you'd rather bypass all of that customization you can always integrate the originally Stripe.js library and or use Stripe Checkout which is as simple as dropping in a form with key-value pairs inside your application.

Kicking off the build

In previous builds I started from scratch by installing and configuring gems as we needed them. In order to save some time, I decided to create a Rails application template. This approach is super useful if you find yourself reaching for the same files, gems, and other various features a Rails app has over and over. In my exact case, I tend to use gems such as Devise, Guard, Bulma, SimpleForm, and more to create the same type of app for these screencasts.

With all of this said I decided to share my template of which I called Kickoff. In the videos I discuss at greater length how everything here works but to make use of it you can download the repo and cd into it.

From that point, you can create a new Rails app by running rails new myapp -m template.rb. The template.rb file is where all the magic happens. It tells our new app how to configure itself and essentially presents a checklist of tasks to perform. This ultimately saves me a load of time!

Following along

If you used my template you should be in good shape to kick-off building the job board. The main models we will utilize in this project are the User model and the Job model.


Each Job will house quite a few fields which are important for any type of job listing online.

Each Job will feature the following:

  • Title - title:
  • Description - description:text
  • Logo Avatar - via Carrierwave - avatar:string
  • Website URL - url:string
  • Type: Fulltime, Part-Time, Freelance, Contract job_type:string
  • Location - location:string
  • User ID - user_id:integer
  • Remote ok - remote_ok: boolean, default: false
  • apply_url - apply_url:string

Scaffolding this model is relatively trivial with rails. Fair warning that it's a rather lengthy script to run.

$ rails g scaffold Job title:string description:text url:string job_type:string location:string remote_ok:boolean apply_url:string

Notice how I left out avatar and user_id. We add those later as separate migrations where avatar is a string-based column and user_id is an integer-based column.

Each User will have:

  • Name - name:string
  • Email - email:string
  • Stripe ID - stripe_id:string
  • Card Type - card_type:string
  • Card Last 4 - card_last4:string
  • Card Exp Mo - card_exp_month:string
  • Card Exp Year - card_exp_year:string
  • Expires at - expires_at:datetime
  • Admin - admin:boolean

We don't use a scaffold for Users in this app as Devise does most of the heavy lifting for us. Rather than scaffold any model we just perform a few migrations to get our hands dirty.

The first is an admin column. This column as you can probably guess dictates whether a given user is an admin or not. At the most basic form, we need to make a user an admin bt setting the admin column to true. And then in all our views, we can use a clever method to check if this is indeed the case

if current_user.try(:admin?)
 # show something only admins can see here

If you used my initial Kickoff template you should have Devise all ready to go out of the box. This appends a name field to our user model but we want to get a bit more information about the user when it comes time to make a purchase. Those extra bits of information include primarily credit card related information. We can add those as a simple migration all at once.

class AddCardInfoToUsers < ActiveRecord::Migration[5.1]
  def change
    add_column :users, :stripe_id, :string
    add_column :users, :card_brand, :string
    add_column :users, :card_last4, :string
    add_column :users, :card_exp_month, :string
    add_column :users, :card_exp_year, :string
    add_column :users, :expires_at, :datetime

Now since we are using Stripe charges we don't necessarily require this information on a given user. If you, for example, wanted to add some sort of subscription service to your app you might be better off saving this type of data. For our app, I just wanted to show by example. In future apps, we will look into the subscription model using Stripe and/or Braintree as a merchant.

Continuing on

I think from here it's best to follow along watching the videos. The bulk of implementing a payment gateway into an app is knowing where it will live and how a user must interact with it before, during, and after purchase. With Rails and Stripe, you can hook into parameters and events to build a payment flow of your dreams. This app starts small with charges but I plan to scale more apps to have a subscription type of flow and even possibly utilize Stripe Connect where you can be a merchant who allows each of your users to both send and receive payments using Stripe as well. Until then I hope you enjoyed this build.

If you haven't checked out the previous builds find those linked below:

  1. Let's Build: With Ruby on Rails - Introduction
  2. Let's Build: With Ruby on Rails - Installation
  3. Let's Build: With Ruby on Rails - Blog with Comments
  4. Let's Build: With Ruby on Rails - A Twitter Clone
  5. Let's Build: With Ruby on Rails - A Dribbble Clone
  6. Let's Build: With Ruby on Rails - Project Management App
  7. Let's Build: With Ruby on Rails - Discussion Forum
  8. Let's Build: With Ruby on Rails - Deploying an App to Heroku
  9. Let’s Build: With Ruby on Rails – eCommerce Music Shop

The Videos

Part 1

Part 2

Part 3

Part 4

Part 5

Part 6

Part 7


This series has been really fun for me. It probably goes without saying that this has also been a huge undertaking. I appreciate the attention it getting and can't thank you enough if you've already subscribed to my YouTube channel or my weekly newsletter.

Shameless plug time

Hello Rails Course

I have a new course called Hello Rails. Hello Rails is modern course designed to help you start using and understanding Ruby on Rails fast. If you're a novice when it comes to Ruby or Ruby on Rails I invite you to check out the site. The course will be much like these builds but a super more in-depth version with more realistic goals and deliverables. View the course!

Follow @hello_rails and myself @justalever on Twitter.

Link this article
Est. reading time: 9 minutes
Stats: 3,583 views



Part of the Let's Build: With Ruby on Rails collection