Writing tests for a multi-tenant, multi-subdomain app turns out to be very tricky to figure out, e.g.: I saw that, and understood the frustration. Integration tests ("request specs" or "feature specs") are built on a stack of frequently changing libraries and shifting API's. And the recipe for subdomain-aware testing isn't documented in any particular tool's notes. … Continue reading Testing the multi-subdomain Rails app
Tag: Rails
A Docker dev config for Ruby on Rails
I use Docker for all my client work, and most of my personal projects too. I love it. It's saved me a ton of money because it uses so much less RAM than Vagrant — what I had been using. Benefits of this config Just docker-compose up to set up and launch the dev environment … Continue reading A Docker dev config for Ruby on Rails
A Benefit of Rails: Surrogate Keys
Today I helped a client wrestle with a database task which concluded: . . . We'll have to watch out inventing new "fake" customers because one day there may be a real customer with our made up ID 😦 This is a problem in lots of apps, but not in Rails. Rails enforces the "best … Continue reading A Benefit of Rails: Surrogate Keys
Self-validating Ruby objects with ActiveModel Validations
I'm importing lots of CSV restaurant inspection data with Ruby, and I need to make sure the cleaned up data matches the spec. For example, a violation must have a business_id and date. It can optionally have a code and description. My goal was to be able to write a class like this: ...and it would … Continue reading Self-validating Ruby objects with ActiveModel Validations
Yes, Rails does support case-insensitive queries
They're unfortunately just a little buried and a little undocumented. And so conventional wisdom is that Rails doesn't do case-insensitive finds. But in fact it does: Example 1: Find all the statutes whose name begins with texas, case-insensitively: Example 2: Same query, using the excellent Squeel gem which makes this a little nicer: Results: Both examples generate … Continue reading Yes, Rails does support case-insensitive queries
It is supremely important that we ensure our data is safe. . .
. . . it is supremely important that we ensure our data is safe, consistent and reliable. We can dramatically increase these factors by taking full advantage of the tools at hand. Yes. This is the most critical, important task in software development. A great set of posts, Coding Rails with Data Integrity by Jay … Continue reading It is supremely important that we ensure our data is safe. . .