...update cucumber Make sure you have a recent version of geordi (it doesn't belong in your Gemfile!): gem install geordi Check if you're using Transforms Transform is no...
...DateTime.strptime is not what you want You may eventually encounter DateTime.strptime. It's a "better" Time.parse where you can actually define the date format to parse, e.g. >> DateTime.strptime...
...If you use Rails' time_zone_select, you will be juggling zone names like "Berlin" which are actually unsupported. Unsupported zone identifiers are silently discarded and you'll end up...
In long diffs, it can become impossible to spot small changes in larger blocks of moved code. This may be either a method that was moved from the top to...
Software engineering principles Read about the following software engineering principles and code smells: Single Responsibility Principle Law of Demeter
...component is using this class to render and modify some html, it may fastly become boilerplate to define every call of the method. Here callFake comes in handy, because it...
...of any dependent on the received arguments without having to know the exact arguments beforehand: spyOn(Random, 'shuffle').and.callFake((array) => array.reverse()) Now you can just assume any result of your...
...file. Note that this is # not guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true...
In modern default RSpec configurations, your tests are usually run in random order. This helps to detect "flickering" tests that...
Rails 7.1 added the normalizes method which can be used to normalize user input. It lets you define the fields...
When using Rails to truncate strings, you may end up with strings that are still too long for their container...
Development environment setup Rails Composer Basically a comprehensive Rails Template. Prepares your development environment and lets you select web server...
This may be awkward to set up, but will work once you're done. Fun facts:
Recently we detected a memory leak in one of our applications. Hunting it down, we found that the memory leak...
} Enumerable#index_with (Rails 6+) To generate a hash where array elements become hash keys, and values are calculated from them, use index_with. users = User.all
s keeps saturation unchanged. calc(100 - l) inverts lightness. For example, 0% becomes 100%, and 100% becomes 0%. Example usage .demo { --inverted-color: hsl(from currentColor calc(h...
...to be performed around a deploy. Be it to notify operations about changed application behavior, be it to run a little oneline script after the deploy. Most database-related stuff...
While debugging a SPF record I found spf-record.de to be very helpful. it lists all IPs that are covered by...
use Postgres' lower() function add an index on lower(email) Probably the best approach is to just convert emails (and usernames) to lowercase within Rails. Popular authentication libraries...
tl;dr The :is() pseudo selector - specificity of its most specific argument - matches against a comma-separated list of selectors...
In some projects we have issues with flaky tests. The best default is to fix them all. But in some cases it might be a pragmatic way to retry them...
You can not use the hash_including argument matcher with a nested hash: describe 'user' do let(:user) { {id: 1...
The sidekiq-rate-limiter gem allows rate-limiting Sidekiq jobs and works like a charm. However, it needs to be...
tl;dr The :where() pseudo selector - zero specificity - matches against a comma-separated list of selectors. Example Compound selectors like...
Authentication is a special part of web applications. On the one hand, it usually is a crucial security mechanism restrict...
This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not...