ActiveRecord is great way to ensure your models are valid before saving them to the database. But as you add new validations or update existing ones, some of the existing records could become invalid. Do you have any invalid records in your production database?

It’s too late when you discover there are invalid records in your production environment.

  • Maybe a migration failed half way through when you deploy to production “It was working just fine on staging?!”
  • You get notified about a weird bug (and you can’t reproduce it on your dev machine)
  • Someone sends you an email saying that he can’t buy the dancing banana t-shirt on your webstore (and you’re lucky someone contacted you. How many people went to a concurrent webstore?)

Setup active_sanity, run it and fix your records.

  1. Add the following line to your Gemfile:
      gem "active_sanity"
  2. Run rake db:check_sanity on your production database. You should see something like:
    model       | id  | errors
    User        |   1 | { "email" =["is invalid"] }
    Flight      | 123 | { "arrival_time" =["can't be nil"], "departure_time" =["is invalid"] }
    Flight      | 323 | { "arrival_time" =["can't be nil"]
  3. Want to store those “invalid records” in the database to check them in your admin interface? Just run rails generate active_sanity to generate a migration and access the data through a model called InvalidRecord.

Run active_sanity against your production environment, say “OMG!” and go fix your records. Deployments will be less stressful and you’re gonna … Read more

When someone receives an email from VersaPay saying that they’ve been sent money, they need to be able to claim their payment no matter what email client they’re using, and whether or not images are enabled.

We’ve come up with some best practices to balance great looks with a high level of usability in our emails and we’d like to share them with you.

First off, here is what one of our emails looks like with and without images enabled:

You’ll notice in both emails (with or without images) the messaging is clear:

  1. Someone has sent you money
  2. The reason they sent you money
  3. Here’s how you get your money

Tip 1: Don’t rely on images, always have a backup plan

Since many (most?) email clients remove images by default, it’s smart to never rely exclusively on images for anything mission-critical (call to action buttons, headings, backgrounds, etc).

You’ll notice that in our emails, the yellow call-to-action button and its text are visible and totally obvious whether or not images are enabled. In the worst case scenario, the user won’t see the nice gradient background but still knows exactly where to click to claim their payment.

This works because we use an image only for the background of the button, but not the button text itself. We also apply the image background with a BACKGROUND attribute and fall back on a plain yellow background color with the BGCOLOR attribute that the user will see if images aren’t enabled.


Read more

VersaPay lets you create Pre-Authorized Debit Agreements (PAD) with your transaction partners to pay monthly bills such as, phone bills, rent, or other recurring payments.
Whether you are using VersaPay for your personal life or for your business, using VersaPay’s new Recurring Payments feature has major advantages over the traditional method of filing though a bank.

Why your Business will love VersaPay’s Recurring Payments:

Focus on running your business – we will focus on your payment security
VersaPay will handle everything from enrollment, PAD management and identity validation, so you don’t need to worry about security of your customers’ sensitive banking information.

Rest easy knowing that your bills will be paid on time
VersaPays’ Recurring payments let you better forecast your cash-flow by ensuring you are paid the correct amount, on time, every-time.

Manage incoming payments from one simple dashboard
Manage and view all of your incoming payments online in 1 place.

PAD Agreements

Build an integrated, paperless billing system with our Recurring Payments API
Our API makes it easy for you to integrate VersaPay with your accounting software to create an enterprise-grade recurring billing system.

Why your transaction partners will love VersaPay’s Recurring Payments:

It’s hassle free and easy to get started
Setting up recurring payments makes your life easier, plus they can be set up online overnight, without ever leaving your house.

Helps you save time
Removes all the hassles of regular bill payments, you don’t need to remember to post a cheque each month.

Its a convenient way Read more

A great way collect money for a raffle, event, or charity is by having an online payment method. With VersaPay you can simply add a payment button or link to your website.

Payment buttons and links are a simple way to accept payments through your website or email without the need for custom programming. Clients or donors can send your organization money directly from their bank account simply by clicking a link from your website, an invoice, or email.

Follow these steps to create a payment link in your VersaPay account:

1. Reference the sample Payment Link URL below:


Here is a list of available fields.
Note: update the fields according to the color in the sample URL

API Token URL Explanation

2. To find your API token, select “Edit Account Settings” in your Quick Links toolbar.

Quick Links Toolbar

3. Under the API Keys Field, select the API Token (if you do not have an API token, reference API Tokens under Account Settings).

API Token (Active)

4. Update the remaining fields as applicable.

5. Once your Payment Link URL has been created, add it to your Payment Button either on your website or donation form.

Benefits for the Organization:

1. Money is deposited directly into bank, no need to worry about losing payments or depositing multiple checks
2. All payments are tracked online and are easy to export for reporting purposes
3. Knowing the current status of payments and forthcoming funds

Benefits for the Contributor:

1. Easy to donate online, no cheque writing
2. Know you money is … Read more

Cucumber Tips

VersaPay’s development team have built the VersaPay app using Ruby on Rails. Our team often uses cucumbers to test our app and Philippe Creux has shared some of their best practices below. We hope you find this post useful!

After (My) RSpec best practices and tips, I’m happy to share my Cucumber best practices and tips! This article will help you organize, clarify and reduce the size of your cucumber scenarios.

1. Organize your garden

Keep your feature files organized by grouping them by business object, then action and context if any. I put all the feature files in the same directory. For instance:


The steps specific to the application should be organized by business object as well (bank_account_steps.rbuser_steps.rb…). Keep the file organized grouping the steps by GivenWhenThen. Do not overload the files generated by Cucumber likestep_definitions/web_steps.rb and support/env.rb with your own steps, helpers or setup code. These files are likely to get overwritten when you update Cucumber so store your stuff in your own files.

2. Custom steps make your scenario DRY and accessible

Scenarios should have the same lifecyle as your code: go Red, go Green, Refactor to make them DRY (don’t repeat yourself) and easy to read. Group multiple steps in one. For instance:

  Given I follow "Send money"
  When I fill in "Email" with "MailGuard('mukmuk','')"
  And I fill in "Amount" with "10"
  And I select "Bank account" from "Source"
Read more