When you find yourself constantly ignoring a RubyMine warning, you can simple disable that warning and de-clutter your editor...
end end def allowed_mime_types %w(image/jpeg image/png) end end This will behave like the solution before: User#portrait will get an expected error message and the User...
Most forms have a single submit button that will save the record when pressed. Sometimes a form needs additional submit...
Assert rmagick provision ... Gemfile gem 'rmagick', '2.13.2' # at this moment the latest stable version config/initializer/carrierwave.rb require 'carrierwave/processing/rmagick' ... and define a...
You will occasionally need to clean out your database while keeping the schema intact, e.g. when someone inserted data in...
...the "space" character class For matching whitespaces in a regular expression, the most common and best-known shorthand expression is probably \s. It matches the following whitespace characters: " " (space)
I've encountered a Ubuntu 16.04 today, where localhost resolved to ::1 instead of 127.0.0.1. This will not usually make...
...no longer recommend this option. After a chrome update, the chromedriver package sometimes lags behind and is not compatible. Install via apt install chromium-chromedriver Option 3: Install via npm...
...no longer recommend this option. After a chrome update, the chromedriver package sometimes lags behind and is not compatible. There's a handy npm package. sudo npm -g install chromedriver...
...from using fixtures over FactoryBot, as fixtures load essential test data upfront at the beginning of the testsuite. Finding peace with fixtures While setting up the database upfront challenges the...
...idea of maintaining a perfectly clean database state at the beginning of each test, with some disciplined practices, handling fixtures becomes quite manageable. Let’s dive into how this works...
...your commits are the changes. Never use merge. You've found some code that belongs to an earlier commit in your feature branch If you already have a "final" (i.e...
git rebase -i master Move the fixup directly below the commit it belongs to. Change the "pick" in front of the fixup commit to "f". Don't touch...
Understand how nested attributes appear in the params. See how the Rails form helpers encode the names of nested...
Getting an entire test suite green can be a tedious task which involves frequent switches between the CLI that is...
Here is a bash script that I use to auto-configure displays on Ubuntu 24.04 with Xorg. Background
This StackOverflow question about nested function definitions in Ruby imparts a good understanding of Ruby's def.
Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background
After running bundler / gem install I could not load nokogiri lately. It died with cannot load such file -- nokogiri/nokogiri.
Use the PDF toolkit: sudo apt-get install pdftk To rotate page 1 by 90 degrees clockwise: pdftk in.pdf cat...
docopt helps you define interface for your command-line app, and automatically generate parser for it. docopt is based on...
To only run the next two migrations: rake db:migrate STEP=2 To revert the previous two migrations:
...for all exceptions (previously true) :none: It will raise for all exceptions (previous default behavior, value false) Using the new default needs to change a RSpec test like this:
Whenever you deploy using Capistrano, a new folder is created within the releases directory on the remote server containing the...
How to ignore new files Globally Add the path(s) to your file(s) which you would like to ignore...
Compromised npm packages have become a weekly occurrence. This is being accelerated by AI tools that find and exploit vulnerabilities automatically. Below you will find minimal configuration to harden your...
yarn add --dev cowsay yarn cowsay hello Further reading Awesome npm Security Best Practices Defending Against NPM Supply Chain Attacks: A Practical Guide
...branches return ranked pages, but we want a ranked list of documents with their best pages attached. So we aggregate results by their corresponding document first, then rank pages within...
...literature default. A page ranked 1 in one branch and 5 in the other beats a page ranked 3 in both. RRF is well suited here because the absolute scores...