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

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

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

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

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

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

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

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

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

blog.cloudflare.com

Two weeks ago, Cloudflare was struck by a global outage that lasted ~30 minutes. The incident was rooted on a...

If you migrate a Rails application from Sprockets to Webpack(er), you can either transpile your CoffeeScript files to JavaScript...

In Ruby you can communicate between processes with sockets. This might be helpful in tests that validate parallel executions or...

If you use transactional_fixtures or the database_cleaner gem with strategy :transaction, after_commit callbacks will not be fired...

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

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

With cd .. you can navigate one directory up from the one you are at now. If you use that a...

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

github.com

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

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

Capybara added a deprecation warning in version 3.35.3 (version from 2019) that shows up if your selector is not of...

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