The Ruby and Rails community linklog
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Submit a post
Post Preview
Note: Only the first pargraph is shown on the front page and overly long paragraphs may be broken up.
KMS now supports Rails 5
Now it’s possible to use KMS in Rails 5 app - https://github.com/webgradus/kms
Keeping Data Integrity in Check: Conditional Unique Indexes for Soft Delete
Soft delete is a pretty common feature in most of the applications. It may increase complexity of the queries, nevertheless, not deleting anything might be a right default as the data might prove to be useful in the future: for restoring if a record was removed by mistake, to derive some conclusions based on statistics and plenty of other purposes. It may seem like it’s a pretty trivial thing: just adding a column like deleted_at and filtering out records that have this value present. But what happens when you need to do some proper uniqueness validation on both model layer and database level? Let’s take a look what kind of problem can easily be overlooked and how it can be solved with a conditional index. [more inside]
Why isn't server-side JavaScript more popular?
For some reason no one in the Rails community talks about this technique. Either no one is actually using it or no one is admitting that they are. Why is this…? Here’s my attempt at solving this mystery
Ruby on Rails implementation of a (proper) Ranking/Popularity system
We live surrounded rankings everywhere. But for some reasons we developers have just the wrong intuitions on how to calculate “popularity” to sort items in rankings. This is not new, the math has been sorted out since the early 1930’s and I read at least one good post in 2009 about it. So let’s see how to properly calculate popularities in Ruby.
Review: Keep Ruby Weird 2016
Keep Ruby Weird could easily be called “Remember Ruby’s Fun”. It’s a one day, one track conference in Austin that pays homage to the days of why’s (poignant) Guide to Ruby. Born in Austin, whose slogan is “Keep Austin Weird”, the city and conference didn’t disappoint. After parking my car in the hotel garage, I stepped into the elevator, and met with this disaster… Read More
String#concat, Array#concat and String#prepend take multiple arguments in Ruby 2.4
Ruby 2.4 now allows concat and prepend methods to take multiple arguments. [more inside]
Using LetsEncrypt SSL with Sinatra on Heroku
This is a short and straightforward tutorial showing how to use Sinatra on Heroku with an auto-renewing SSL certificate from LetsEncrypt. [more inside]
[Screencast] Rails API - Throttling with Rack::Attack
Save expensive calculation time using Rack::Attack, we will learn how to limit requests coming into our application. This gem not only limits requests, but can be used to blacklist or whitelist users as well. https://www.driftingruby.com/episodes/rails-api-throttling-with-rack-attack
Stubbing External APIs with WebMock
I’ve been testing code that uses third-party APIs for almost as long as I’ve been writing Ruby, but it wasn’t until recently that some particularly heavy integration requirements got me thinking about the right way to go about it. In this post, I describe the approach that I’ve been using to write fast, manageable tests for distributed systems using WebMock.
Better File Uploads with Shrine: Processing
This is the 4th article in the series of posts about the Shrine file attachment library. In this post I talk about various ways in which you can do file processing with Shrine, including manual processing, external processing, and processing on-the-fly. Read all about it here.
Version Compatibility Test
How many times have you run into version compatibility issues that takes up a majority of your troubleshooting time? Wouldn’t it be nice if we could come up with a specification? Who reads the details buried in the readme files? Even if you diligently did read it, is it possible to juggle all those compatible version numbers for different version of the library/framework in your head while troubleshooting? Wouldn’t it be nice to make it a executable script? Read Version Compatibility Test to find out how you can cut down time spent in troubleshooting.
Decorator Pattern in Ruby
Decorators allow us to add behavior to objects without affecting other objects of the same class. The decor… Read More
Continuous Integration and Deployment for Ruby projects with Bitbucket Pipelines
Bitbucket Pipelines has been released recently and i will show how you can use it for a Rails project in this blog post.
Row Fragmentation for Better Locking Performance
This blog post discusses a strategy for distributing a single resource’s lock among many rows to improve locking performance in a database like Postgres (with a few code examples in Ruby).
ActiveJob Basics in Rails 5
Checkout the latest episode covering ActiveJob basics in Rails 5
Using the Push API with VAPID in Ruby
You can now use the Push API in Chrome and Firefox with “voluntary application server identification” (VAPID); in other words, you don’t need to register any app credentials with individual push servers to use this new browser protocol. This post demonstrates the “how to” with the webpush Ruby gem: https://rossta.net/blog/using-the-web-push-api-with-vapid.html
Natural Language Generation in Ruby (with JRuby + SimpleNLG)
I wanted to write full English sentences from data structures without doing the naive string manipulation routing. So I ended up creating 2 open source projects to help out anyone who may need Natural Language Generation (NLG). Check my blog post about this endeavor.
Five ways to write a flaky test
I’ve spent many hours identifying and fixing flaky tests in a 50k tests suite. [more inside]
State Change through Forms and Cleaning up Layouts
In the first free episode we show you how to trigger a state change (state machine) via your form. The second free episode shows you how to keep your layouts clean using content_for and yield. [more inside]
Building a Photo Gallery that automatically tags images
As a follow-up to our comparison of different image-tagging APIs, in this tutorial we’re building a simple application that automatically tags uploaded images using Clarifai, one of the compared API providers.
Debugging With Byebug
Every now and then, we face a nasty, complicated bug. When simple debugging isn’t enough, it’s time to bring out the big guns: a debugger.
Enforcing unique jobs in Karafka and Sidekiq for single resources
When working with multi threaded and multi process systems that consume messages in parallel, you need to be able to enforce some limitations on the processing order. This is especially important, when you process data related to same elements. In this article, I describe some of the solutions suitable for both Karafka and Sidekiq.