Two weeks ago, Cloudflare was struck by a global outage that lasted ~30 minutes. The incident was rooted on a...
...polymorphic association. class Event < ApplicationRecord has_many :letters, as: :record end class Letter < ApplicationRecord belongs_to :record, polymorphic: true end event = Event.new.letters.build event.save! # => ActiveRecord::RecordInvalid: Validation failed: Record must exist...
If you use transactional_fixtures or the database_cleaner gem with strategy :transaction, after_commit callbacks will not be fired...
If you migrate a Rails application from Sprockets to Webpack(er), you can either transpile your CoffeeScript files to JavaScript...
...member', :home_page end It has some limitations: Only works for singular member references ("belongs to"), not for a collection of references ("has many") No support for deletion (but could...
This note describes how to kick a user out of a Rails application after she hasn't requested an action...
tl;dr: Use event.currentTarget unless you are absolutely certain that you need event.target. Since it hasn't been written down...
...skipping asset compilation when assets have not changed? Turns out there is an even better way to speed up Capistrano deployments with asset compilation – and it's even simpler.
...when you run a Selenium test with Capybara. This will help you understand "impossible" behavior of your tests. When you run a Rack::Test (non-Javascript) test with Capybara, there...
...you. But sometimes the complexity will bleed through, causing your tests to show "impossible" behavior. Here is some unexpected behavior caused by the interaction of threads and processes:
After updating Rubygems you see a wall of deprecation warnings like this: NOTE: Gem::SourceIndex#add_spec is deprecated, use...
...should see the following ([\w]+) table:?$/ do |name, expected_table| name = name.underscore table_element = begin element_at("table\##{name}") rescue Webrat::NotFoundError begin element_at("table.#{name}") rescue element_at...
We had a strange behaviour on one of our mariadb-servers: Everyday at around midnight we saw that the root-account on one of our servers is trying to access...
...a "add new user" forms. Chrome developers say this is by design as they believe it encourages users to store more complex passwords. Recommended fix for Chrome and Firefox
When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...
Unpoly's [up-observe], [up-autosubmit] and [up-validate] as well as their programmatic variants up.observe() and up.autosubmit...
With cd .. you can navigate one directory up from the one you are at now. If you use that a...
Capybara allows you to select DOM elements, e.g. by using field, find_field(...) or field_labeled(...): role_select = field_labeled...
If you are using scrum in a project you might be familiar with planning poker, a playful way to agree...
When storing files for lots of records in the server's file system, Carrierwave's default store_dir approach may...
In Ruby you can communicate between processes with sockets. This might be helpful in tests that validate parallel executions or...
On your local system that only hosts non-critical development data and only you have access to, you can store...
Capybara added a deprecation warning in version 3.35.3 (version from 2019) that shows up if your selector is not of...
...new value (be aware that you should use a secure and salted hash) or better call the the_user_to_log_out.reset_remember_token! method that does the things for you.
Note that you should disable the Java plug-in in your browsers after installation. Ubuntu >= 12.04 Java 11