Extending Engine Models in Rails 4

For a SaaS platform I’m working I decided to build it in Rails instead of Django. To get up up to speed with the latest developments in Rails 4 I bought Ryan Bigg’s book, Multitenancy with Rails. In the book he takes you through how to set up a multi-tenant system with Rails and Postgres, with the multi-tenant part of the system encapsulated as a Rails engine. Having the multi-tenant part split out into an engine is nice from a … Continued

Sending Emails Using Rails and Bootstrap

If you’ve built your site’s look and feel using Bootstrap and you’re now looking to start sending emails with similar styling then as you are no doubt aware, email clients are generally extremely limited in their understanding of CSS in particular and so we’re going to have to do a bit of work. The topic of email HTML and CSS rendering is a complex one with an increasing number of caveats as you try to support more email clients. Some … Continued

Safer (Soft) Deletion in Django

The Problem The default behaviour in Django is to cascade deletes, such that when a record is deleted any records that are associated with this record (via a foreign key) are also deleted. This preserves referential integrity within the database which is what we want. Where this can be problematic though is that one careless or mistaken deletion in the admin can cause any number of related records to also be deleted, with no neat way to undo the operation … Continued

Porting Apple’s Core Data Books Sample Project to RubyMotion

In this post we’re going to reconstruct the Apple sample project Core Data Books, building it step by step from scratch using RubyMotion. This will take us through: Use of NSFetchedResultsController to manage a collection of objects to be displayed in a table view, Providing undo and redo functionality via the device shake gesture, Use of a nested context to isolate changes made in an add operation. The app presents a table view of books following the master-detail pattern; tapping … Continued

Simpler Core Data with RubyMotion and CDQ

Core Data can be one of the more intimidating Apple frameworks to work with, in part because it doesn’t quite have the polish that many of the other frameworks have but also because when you’re dealing with users’ data it is worth treading carefully: imagining correcting a poorly-executed migration on thousands of remote devices should be enough to persuade anyone of that! Luckily, RubyMotion and Core Data Query can make Core Data a lot more familiar and manageable, particularly if … Continued

Exposing Private Methods Cleanly When Testing iOS Apps

When unit testing iOS apps you will want to be able to test the internal methods of your classes in your test suite but from the outside the non-public methods won’t be readily accessible. One way around this could be to make the method public; this would allow you to test it and wouldn’t break your app but now you’ve added clutter to your interface which over time could add up to a significant problem, particularly if you (or a … Continued

Recovering from Burnout

Previously when I thought of burnout I thought only of incredibly long work hours and lives out of balance, with little sleep, no exercise and so on. While on a visit to Japan earlier this year I was talking to a Big Issue seller while I waited for a friend at a train station near one of the more upmarket areas of Tokyo. He was telling me about the people who buy regularly from him and there emerged a disturbing … Continued

How to Launch a $30k iOS App using Amazon Rankings as a Guide

If you’re familiar with AppSumo and its founder Noah Kagan you will know that one of the tricks Noah and his team use to come up with so many products and business ideas is that they look at what’s already popular, what’s already selling, as part of their research. One way to do this is to take a look at a site like Amazon and browse their rankings to see what people in your (or almost any) country are buying. … Continued

Worksheet: Offering Retainer-based Services for Recurring Revenue

Problem:¬†You’re a freelancer or an employee and you would like to have your own clients. However, the time involved and lack of certainty in finding new clients each month is wearing you down. You would like to take the one-off services you are offering now and turn them into subscription services that your clients will pay for each month, thus giving you some recurring revenue. Aim: By the end of this worksheet you should have identified: The skills you have … Continued