Lost your sourcemaps after upgrading to Webpack 2?

While migrating an application from Webpack 1 to the latest and greatest version 2, I noticed that our sourcemaps were gone. Even though I had set the correct devtool values in my Webpack configs.

After some (read lots) of debugging, I found that the UglifyJsPlugin plugin changed its default behaviour and nowadays you need to include the  { sourceMap: true } option when configuring it.

Proper Counter Cache Migrations in Rails

A lot of people are doing a lot of heavy lifting in their database migrations when deploying. That might work well for people when their data set is ~1 000 records, but when you are working with 500 000+ records, that’s just not feasible.

There’s a lot of bad advice in terms of counter_cache and Rails so I wanted to make sure this one got some extra visibility.


Migrate to Ruby on Rails 5.x using RocketPants

At Sparta, we’ve been using a Gem called RocketPants since day 1 (roughly three years now) to easier maintain, version and develop our internal API. The Gem has since then lost a decent chunk of its community and it looks like less people are using it.

I would guess that since the Rails API Gem was merged into Ruby on Rails with the 5.0 release, the need for a Gem such as RocketPants shrunk.

Anyway, I’ve been doing some work on making the Gem support Ruby on Rails 5.0 and 5.1, and it seems like some other people were stuck on the 4.x branch of Rails because they were unable to upgrade.

RocketPants with support for Ruby on Rails 5.0 (and 5.1) : https://github.com/Sutto/rocket_pants/pull/143/files

I’ve been using it myself on Ruby on Rails 5.0 for the last year without any issues, so the whole Gem feels fairly stable.

This is not a permanent solution as the Gem has lost a big part of its community and we want to avoid getting stuck on a Gem that will not be developed any further, I will follow up in another post on how we at Sparta will migrate to another solution. Most likely we will be using the built in Rails API.

In addition, my colleague Yi got the rocketpants-rpm (provides support for making RocketPants::Base work with RPM) gem up and running for Rails 5 as well. It’s available under our Github organisation here.


Continuous deployment for free when building a mobile iOS app and API


I am a big fan of CI and CD and the overall mentality that you should always be deploying. There should never be any stress involved in the fact that you are deploying. You should always be able to trust your code.

While building my latest hobby project, one of the first thing I started doing was to setup all the environments that was needed to make sure I don’t break anything as the project grows. Since it is a hobby project, I would prefer to get as far as I can with free tiers available at different providers.

In this article I will outline my setup and how you can grow into the paid plans at each provider while taking away the initial costs. Making sure that the only initial cost is a smaller amount of development time.

Technology Stack

The backend is a Ruby on Rails API that is serving JSON. This gives me a few things I need to test in the backend:

  • API Requests
  • Controllers
  • Models

All of the above are tested using RSpec.

The mobile iOS app uses Cedar as a test framework and I pesonally strive to maintain a good test coverage (of course, where it makes sense).

CircleCI (iOS)

CircleCI just opened up mobile iOS support as a beta feature and you can request access to it by sending them an email and then activate it:

CircleCI now offers Beta support for building and testing iOS (and OSX) projects. To enable this feature, go to Project Settings > Experimental Settings and enable the “Build iOS project” experimental setting. This will cause builds for this project to be run on OSX machines rather than the usual Linux containers, and iOS-related build and test commands will be automatically inferred.

They offer one private project for free which suits us perfectly, since we only need one for the iOS app.

Fabric (iOS)

Beta by Crashlytics is a cross-platform toolset built to make beta distribution easy. I followed a sample project that was available for CircleCI and Testflight and modified that to get my CircleCI to push my builds to Fabric.

Codeship (Web)

Codeship is a continuous integration & delivery as a service provider. They also offer a free tier with these restrictions:

  • 1 concurrent build
  • 1 test pipelines
  • 100 private builds / month
  • 5 private projects

It will not scale very well if we start deploying a lot, but it will get you quite far to start off with. They have an awesome support for Ruby on Rails so in this case, its extremely easy to get up and running!

Heroku (Web)

Heroku is a cloud platform as a service. That means you do not have to worry about infrastructure; you just focus on your application. They offer instant Deployment with Git push, where we will instead push our code to GitHub and let Codeship run the CI and deploy to Heroku instead if everything gets a green light

Slack (All)

In my opinion, Slack is like IRC but for companies. You can create open channels for the projects, groups and topics that the whole team shares. I suggest you create a #notifications channel where all your CI posts their status updates when a build fails (or passes). This way the entire team knows when something goes awry.