When the Ruby parser module of Ruby-GetText comes across a file in one of its search directories (e.g. lib/scripts...

When you use the send_file method to send a local file to the browser, you can save resources on...

...to a value. The validation is skipped silently when terms is nil. While this behavior is useful to validate acceptance in the frontend and not the admin backend, it also...

Active Record's select method allows you to make use of the power of MySQL select statements. On the one...

...include(3, 4, 5) evaluates to: NOT( .to include(3, 4, 5) ) However, it behaves like: .to (NOT include(3) && NOT include(4) && NOT include(5) ) Warning

When paginating records, we usually need to know the number of total records in order to render pagination links. Popular...

Yesterday, Rails fixed a security issue (CVE-2014-3514) in Rails 4+. It was possible to use .where...

web.archive.org

Capistrano 2 brings the shell command which allows you to run commands on your deployment targets. There is also invoke...

...new RegExp('^(\\d+) users') # => /^(\d+) users/ Our expression above now works only at the beginning of the matched string, looks for a number (\d+ [1]) and also captures that. Sweet...

github.com

The linked rbenv plugin rbenv-each is very helpful to keep QoL gems up to date that are not part...

...might have a negative impact on your application's performance. We did not yet benchmark it, but using it for elements that are rendered very often is probably a bad...

tl;dr Since Rails 6.1+ you can use .compact_blank or .compact_blank! to remove blank values from collections (e.g...

With puma you can have concurrent requests. There are two concepts on how Puma can handle two incoming requests: Workers...

In order to request a SSL certificate from any dealer, you usually need a CSR certificate. As both the CSR...

github.com

The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall...

...nested, :inverse_of => :parent accepts_nested_attributes_for :nested end class Nested < ActiveRecord::Base belongs_to :parent validates_presence_of :parent_id # <- end With the parent already persisted creating nesteds...

...soften the validation to only validate on the associated object: class Nested < ActiveRecord::Base belongs_to :parent validates_presence_of :parent # <- without `_id` end Drawback With this softened validation now...

You can use JavaScript to get or set cookie values on the client. Using the vanilla JavaScript API

angular-tips.com

Angular comes with different types of services. Each one with its own use cases. All of these services are singletons...

The goal is to get Jasmine specs running in a Rails project using Webpacker, with the browser based test runner...

...origin (e.g. git fetch and git status). You should be 0 commits ahead or behind. Add and commit a file touch .please-update git add .please-update

...is no way to make GitHub do this nicely. :( If you know of a better approach, please let me know...

tl;dr In Chrome DevTools in the Sources tab you can activate Event Listener Breakpoints for debugging events. Example

drafts.csswg.org

...invalid calc value is ignored, so you might end up with missing or "random" behavior, depending on where you do this. The above example is valid once you use zero...

makandra dev
stackoverflow.com

Using git rebase can be painful but luckily you can resort to cheating with git reset and committing anew.

We recently had a problem on a Memcache cluster, where one of the servers showed a significantly worse cache hit...