makandra dev

...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...

kernel.org

...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

ruby-lang.org

Ruby 3.0 introduced a breaking change in how it treats keyword arguments. There is an excellent blog post on the...

github.com

When handling nested hashes the RSpec output is often hard to read. Here the gem super_diff could help.

makandra dev

...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.

This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting...

...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...

DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It...

...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...

makandra dev

...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...

...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...

blog.saeloun.com

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...

When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into...

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...

You can use RSpec::Matchers.define_negated_matcher to define a negated version of an existing matcher. This is particularly useful...

...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...

In a web application you sometimes have tasks that can not be processed during a request but need to go...

The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2, e.g...

For Rails models where only one of multiple attributes may be filled out at the same time, there is no...

When you use Sentry to monitor exceptions, an important feature is Sentry's error grouping mechanism. It will aggregate similar...

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...