If you want to see how long your database queries actually take, you need to disable MySQL's query cache...

...is a fix to SafeBuffer#gsub. Note that it will only fix the $1 behavior, not give you a safe string in the end (see below). Example def test(input...

...really expect outside code (read: Gems) to not use $1 (and there is plenty, believe me) when calling gsub on an input that may be a SafeBuffer, you need to...

...reject_if: :all_blank # Ignore the blank template record end class Image < ActiveRecord::Base belongs_to :gallery mount_uploader :teh_image, YourUploaderHere # Mount Carrierwave on attribute :teh_image end

...to automatically fix the whitespace, see below. (Note that this might lead to unexpected behaviour e.g. in Markdown documents.) The global git hooks live in $PREFIX/share/git-core/templates/hooks (where $PREFIX is probably...

Usually you add errors to :base in ActiveRecord, in case no appropriate attribute could be used to add the error...

makandracards.com

...of time, but it will always be retried at least a second time. This behavior allows with_scope to be patient, and it must be patient, as explained below.

makandra dev
w3.org

This decision tree describes how to use the alt attribute of the element in various situations. For some types of...

You can tell npm to install a package globally with npm -g install @puppeteer/browsers. However, it seems that its not...

...Use the attached Modularity below to add such a magical array to your model. Besides using the trait, you will need to implement two methods to synchronize the string array...

When you have many changes, and you want to spread them across different commits, here is a way to stage...

Chromedriver (or selenium-webdriver?) will not reliably scroll elements into view before clicking them, and actually not click the element...

docs.ruby-lang.org

The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000

...calls html_safe if you're not escaping. FWIW, an HTML string may easily become invalid when truncated, e.g. when a closing tag gets chopped off. However, when the input...

For my Gem Session project Holly I ran the Ironman of drag'n'drop implementations: Dragging in nested lists

As an application exists, data accumulates. While you'll be loosely monitoring the main models' record count, some supportive database...

If you use a newer SSH key generated with the ED25519 algorithm instead of RSA (see Create a new SSH...

Note: Making a reverse proxy with nginx is much more straightforward. A reverse proxy is a "man in the middle...

...its mount path. It starts with /media/. Open a terminal and sudo su to become root. We require root for everything. Use dd to create an image of your encrypted...

makandra dev

...which point the exception was thrown. def self.search_solr_with_exception_handling(*types, &block) begin search_solr_without_exception_handling(*types, &block) rescue Errno::ECONNREFUSED, Timeout::Error => e message = "Verbindung...

When making cross-domain AJAX requests with jQuery (using CORS or xdomain or similar), you will run into issues with...

github.com

Zeitwerk is the new autoloader of Rails. It is mandatory starting with Rails 7.0. Sometimes, a model needs to know...

Rails comes with grouped_collection_select that appears to be useful, but isn't. As an alternative, consider the flat...

CoffeeScript and JavaScript (ECMAScript) both have operators in and of. Each language use them for more than one purpose. There...

Controllers Take care when defining nested resources, as they don't behave identical to namespaced resources: namespace :users do resources :sign_ups, only: [:new] end # GET /users/sign_ups/new...

...in controllers/sign_ups_controller.rb in order to make the second example work. You can alter this behaviour with a custom controller path, as shown in the very first example of this card...