In Rails, we usually have a mailer setup like this: class MyMailer < ActionMailer::Base def newsletter mail to: 'receiver@host.tld',

This Capistrano task runs a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log...

Given there is a user with an attachable avatar: class User < ApplicationRecord has_one_attached :avatar end

When doing some meta-programming magic and you want to do something for all attributes of a class, you may...

So you are comparing two Time objects in an RSpec example, and they are not equal, although they look equal...

Not all email clients support external images in all situations, e.g. an image within a link. In some cases, a...

...token] is nil, you'll retrieve a random user that doesn't have a token set. Instead do token = params[:password_reset_token].to_s if token.present? User.find_by_password...

Rails comes with grouped_collection_select that appears to be useful, but isn't. As an alternative, consider the flat...

Basically, you now need to know if your project uses a "real" time zone or :local, and if config.active_record.time_zone...

I recently stumbled upon the Rails feature composed_of. One of our applications dealt with a lot of addresses and...

When delivering non-public uploaded files (images, documents etc), one has to decide whether and how to do authorization. The...

stackoverflow.com

Ruby has a set of methods to convert an object to another representation. Most of them come in explicit and...

Icon fonts like Font Awesome are infinitely scalable, look great on high-DPI displays and will give your app a...

Here are some hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts

HTTP header values must only contain low-ASCII (7-bit) characters for safe transport. From RFC 7230: Historically, HTTP has...

This card will show you a cool way to define a class using Struct.new. A common usecase for Structs are...

Rails 7.1 added the normalizes method which can be used to normalize user input. It lets you define the fields...

makandra dev
github.com

PDFKit converts a web page to a PDF document. It uses a Webkit engine under the hood...

I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...

While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic...

Just like Ruby Gems tag their version releases to the corresponding Git commit, it can be helpful to track production...

Rails 7.1 added a new method Rails.env.local?. If you want to stub the Rails env correctly, use ActiveSupport::EnvironmentInquirer like...

When you need to store structured data (like Ruby hashes) in a single database column with ActiveRecord, a simple way...

Ruby's regular expressions can be represented differently. When serializing them, you probably want to use inspect instead of to...