To test whether two arrays have the same elements regardless of order, you can use the =~ matcher in RSpec < 2.11...
If you encounter the error message above when running cucumber, just execute... rm rerun.txt ...in the Rails directory.
As far as I know, the only plugin out there that handles this (semantic issue) correctly is Makandra’s Aegis...
...model can either hold a concrete owner class (like. e.g. User) or a polymorphic belongs_to or multiple optional belongs_to associations. class CreateBlobOwnerships < ActiveRecord::Migration[7.2] def change
...false, foreign_key: true, index: true t.timestamps end end end # app/models/blob_ownership.rb class BlobOwnership < ApplicationRecord belongs_to :active_storage_blob, class_name: 'ActiveStorage::Blob' belongs_to :user end class CustomDirectUploadsController < ActiveStorage...
When working with custom transactions and use ActiveRecord::Rollback you may encounter unexpected behaviour if you try to roll back your changes. tl;dr When using nested transactions, ActiveRecord::Rollback...
...only roll back the inner, but not the outer transaction. You can fix this behavior by using transaction(joinable: false) but this leads to a bunch of different problems.
...squash these small commits to meaningful, bigger ones. When merging into master it's better to have only few (or maybe just one!) commits. Each of them should have a...
...but review your final commit before pushing. Look out for changes that don't belong to your issue (and are usually in place you never touched) when you open a...
...is already present in the gem. Try to write your code so that everyone believes it has been there from the beginning. When adding files, you need to require them...
...yourself. Look around how similar files are being required, and try to find the best spot. Your last resort is lib/$gem_name.rb. One thing to keep in mind is that...
# => 3 "foo".class # => String "foo".html_safe.length # => 3 "foo".html_safe.class # => ActiveSupport::SafeBuffer The behavior of SafeBuffer differs from a String in one way only: When you append a String...
...if it is safe. To achieve this we can simply use SafeBuffer's concatenation behavior: # ✔️ Safe def group(content) html = "".html_safe html << " ".html_safe html << content html << " ".html_safe...
...is being validated. This way they will be right next to defaults and other behavior for that method: describe Report do describe '#currency' do it { is_expected.to allow_values('EUR', 'USD...
Notes compare writes it's result to STDERR. A lower score is better, I'd test for a threshold like <= 5. There are different comparison metrics available
...to work, and SameSite=Lax (new Chrome default, gradually rolled out) is an even better default for cookies. Set SameSite=Strict only for extra security in special cases (see below...
...same site, from the page or from an iframe. This is how cookies have behaved the last decades. SameSite=Lax Only send the cookie in a first-party context (meaning...
Do­nau­dampf­schiff­fahrt Caveat: Unexpected copy & paste behavior Note that when copying a text with soft hyphens, the soft hyphen character will be...
...made within the transaction are rolled back and the exception is re-raised. To better understand how ActiveRecord handles exceptions within a transaction, here is the implementation of ActiveRecord::Base...
...above has all the issues that the transaction-less copy_invoice example at the beginning of this article had. In addition, it might lose money transactions.
...fixed. However, as your frontend adds more JavaScript, AJAX and animations, this test might become "flaky". Flaky tests destroy the trust in your test suite ("I thought this is always...
...before raising NoSuchElementError. This is sufficient for basic, server-rendered application. However, as frontends become more complex (more JavaScript, AJAX requests, animations), race conditions will become too severe to be...
...values, which map to one context, e. g. mail components, in order to provide better readability of your tests or to even make clear a tests fail reason due to...
...ETags. These ETags will never match what your application sees. You can disable this behavior through this directive: DeflateAlterETag NoChange
"Open-source software (OSS) is great. Anyone can use virtually any open-source code in their projects." Well, it depends...
To attach files to your records, you will need a new database column representing the filename of the file...
...nested form. See ActiveRecord: When aggregating nested children, always exclude children marked for destruction. Best practice example Here we will use what we learned above in order to create a...
When you write your next CarrierWave uploader, consider processing your images with libvips instead of ImageMagick. Reasons for libvips
...it with a (lead) developer before it is ready. The backlog Every issue should begin its life in the icebox and only be moved to the backlog if it is...
...to attach a timestamp or content hash to your asset's filenames, e.g. foo.png becomes foo-2179b43e243cf343.png. This way, when the asset changes, its URL changes. You can now safely tell...
...helper attaches an MD5 hash of the file content to the asset. E.g. /app/assets/foo.png becomes: /assets/foo-2179b43e243cf343.png These hashes will only be added when assets.digests is enabled for your environment (it...
If you want to prevent that two processes run some code at the same time you can use the gem...