When you use Sentry to monitor exceptions, an important feature is Sentry's error grouping mechanism. It will aggregate similar...
I encountered a unlucky behavior of byebug 11.1.3 (the most recent version at time of writing) when using it with Rails 6 and it's new autoloading component, zeitwerk. There...
In a web application you sometimes have tasks that can not be processed during a request but need to go...
...shared_examples_for can have parameters. You can simply hand over arguments from it_behaves_like: shared_examples_for 'string equaling another string' do |expected_string| it 'is equal to...
...subject).to eq(expected_string) end end describe 'some string' do subject { 'foo' } it_behaves_like 'string equaling another string', 'foo' end RSpec 1 Use it_should_act_like from...
For Rails models where only one of multiple attributes may be filled out at the same time, there is no...
Building application assets with esbuild is the new way to do it, and it's great, especially in combination with...
I recently enjoyed debugging a Cucumber step that tried to be retryable using a patiently block: Then /^"([^"]*)" should( not)? be...
Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.
When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module. This card describes how to test that extracted behavior without...
...repeating yourself. Note that the examples below use Modularity traits to extract shared behavior. This is simply because we like to do it that way at makandra. The same techniques...
...changes you make to the database will be rolled back on exit. Warning Changes beyond the database (deleting files, sending emails, etc) cannot be rolled back...
When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.
This card will show you how to use git rebase --onto without confusion. Use case: You've got two feature...
class Post < ActiveRecord::Base has_one :attachment end # attachment.rb class Attachment < ActiveRecord::Base belongs_to :post validates :title, presence: true end Issue When creating a post with an invalid...
IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting...
Since I use this a lot in my daily work and there were no scripts working properly for me, I...
To apply transparency to an element, you can use opacity in CSS. However, sometimes you don't want to make...
...index: true option. Use it only inside create_table or for add_reference (= add_belongs_to) statements, and use add_index for other cases. Never use index: true but only...
...between added? and of_kind? While added? might feel more natural to use, it behaves differently than of_kind? because it also compares options from the validation error. of_kind...
TL;DR There are three dimensions you can control when scoping routes: path helpers, URL segments, and controller/view module.
While it might be tempting to set it per project (other devs might benefit from it), you need to do it each time for every project "pollute" a project...
...Middleman brings Haml, Sass, helpers etc. However, it can be configured to do even better. This card is a list of improvement hints for a Rails developer. Gemfile
...helpers in a helpers {...
...} block. However, this does not scale very well. You're best off creating a /helpers directory and putting helper files there just like you know it...
...all Unpoly updates work using AJAX requests, you won't get the more detailled better_errors page with the interactive REPL. Below is an event listener that automatically repeats the...
...full CSS and JavaScript. The code assumes you are using Ruby on Rails with better_errors, which is the default error view that modern Rails versions employ. If you are...
The robots.txt file and HTML tag can be used to control the behavior of search engine crawlers. Both have different effects. robots.txt Marking a URL path as "disallowed" in robots.txt...
Capybara provides execute_script and evaluate_script to execute JavaScript code in a Selenium-controlled browser. This however is not...