When you use method_missing to have an object return something on a method call, always make sure you also...
If you need to make an HTTPS connection to a host which uses an expired certificate, do not disable certificate...
Given there is a user with an attachable avatar: class User < ApplicationRecord has_one_attached :avatar end
When making requests using the http gem you might want to automatically follow redirects to get the desired response. This...
This Capistrano task runs a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log...
In Rails, we usually have a mailer setup like this: class MyMailer < ActionMailer::Base def newsletter mail to: 'receiver@host.tld',
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...
...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...
Not all email clients support external images in all situations, e.g. an image within a link. In some cases, a...
Basically, you now need to know if your project uses a "real" time zone or :local, and if config.active_record.time_zone...
Rails comes with grouped_collection_select that appears to be useful, but isn't. As an alternative, consider the flat...
...custom matchers and other support code. DRY specs Goals You should know the following tools: Shared example groups Nested example groups before(:each) after(:each) let subject RSpec.configure, config.before, config.after...
I recently stumbled upon the Rails feature composed_of. One of our applications dealt with a lot of addresses and...
Ruby has a set of methods to convert an object to another representation. Most of them come in explicit and...
When delivering non-public uploaded files (images, documents etc), one has to decide whether and how to do authorization. The...
Icon fonts like Font Awesome are infinitely scalable, look great on high-DPI displays and will give your app a...
Sometimes you have a maintenance script where you want to iterate over all ActiveRecord models. Rails provides this out of...
I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...
Here are some hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts
Rails 7.1 added the normalizes method which can be used to normalize user input. It lets you define the fields...
Ruby is the programming language we use on the backend. Goals After finishing this lesson you should be able to...
This card will show you a cool way to define a class using Struct.new. A common usecase for Structs are...
PDFKit converts a web page to a PDF document. It uses a Webkit engine under the hood...