In Capistrano 3, your Capfile requires 'capistrano/rails/migrations', which brings two Capistrano tasks: deploy:migrate and deploy:migrating. The former checks...
Ruby 3.0 introduced a breaking change in how it treats keyword arguments. There is an excellent blog post on the...
When handling nested hashes the RSpec output is often hard to read. Here the gem super_diff could help.
When you don't only have a favicon.ico in your project but also PNGs of different sizes and backgrounds, you...
...you obviously do not want to duplicate it and your tests might very well benefit from this approach. Use it with care, however -- doing this more than a few times...
...making the test impossible to read). An alternative is also to hide that functionality behind other steps that do more complex things differently...
By default subscript ( ) and superscript ( ) tags are styled with vertical-align: sub, respectively vertical-align: super by most browsers.
Knowing when to refactor Just feeling like refactoring is not a good reason to do it. Make an educated decision...
Spammers have started abusing other application to send their spam. This works like this: The application has some form that...
This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting...
DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It...
...t raise an error. Instead, rescue the exception type that you are expecting: @user = begin User.power_find(something) rescue ActiveRecord::RecordNotFound User.new end This also applies to the quite popular...
...nil" and "full" rescue blocks that don't explicitly rescue away an error class: begin # do stuff rescue # rescues any StandardError end Note that there may be cases where you...
...installation supports YJIT, by running: $ ruby --yjit -v ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [x86_64-linux] If YJIT is not available, the output of this command will...
...John Doe <user@example.com> Date: Thu Dec 23 13:37:00 2010 +0100 make everything better Once you are done bisecting you can go back with git bisect reset
...time of queries. While they serve similar purposes they do have some differences in behavior and implementation. PostgreSQL Timeout Type: statement_timeout Scope: Applies to all types of SQL statements...
...INSERT, UPDATE, DELETE). Units: Can be specified in various time units (milliseconds, seconds, minutes). Behavior: If any statement exceeds the specified timeout, PostgreSQL raises an error indicating the statement was...
...change the rendered html, some variation of @message.content.body.to_rendered_html_with_layout Changing the behavior of the editor You may want to add some functionality to the editor or remove...
...addEventListener("trix-action-invoke", event => { const { editor } = event.target if (event.actionName === "x-horizontal-rule") { // ... } // Add behavior for the other buttons // ... }) Check the Trix README to check what you can do.
Rails' fragment caching caches subtrees of an HTML document tree. While constructing that tree though, it can be really hard...
If your app does not need to support IE11, you can use most ES6 features without a build step. Just...
...t have control of. Solutions Don't log SQL queries. This is the default behavior of rails but can be changed in the config/environment/production.rb file: config.log_level should not be...
When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into...
...intensive for large files Other ways to solve this problem Other solutions might work better and make more sense depending on what you are trying to achieve. These alternatives could...
When you repeat complex assertions in your tests multiple times, it might be a good idea to extract a custom...
The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2, e.g...
...would allow to detect the end of windows size changing process. Capybara provides a better way to manipulate the browser window which you should use instead: page.current_window.resize_to. Good: Capybara...
...as isolated (more unit like) tests, one might want to test some cookie dependent behavior as a request, helper or model spec too. Since the rspec documentation on testing cookies...
...that into a class to DRY up your code and write solid unit tests. Beware that your class will not be able to read the cookies, since they are only...