A recent Linked In post on memoization got a lot of questions and some pushback, saying that @var ||= function() is good enough. Here’s an example and my reasons for using memoization.More
Tag Archives: Rails
Testing the multi-subdomain Rails app
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.…More
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…More
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…More
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…More