It's possible to implement simple custom RuboCop cops with very little code. They work exactly the same like existing...

When using Rails credentials, you will edit the encrypted credentials for staging or production environments from time to time. To...

This Capistrano task runs a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log...

This card describes different flavors for concatting HTML safe strings in a helper method in Rails. You might want to...

Authentication is hard: there are many edge cases, and most users (including yourself) usually only go the "happy path" once...

...be slightly off their original value. Consider using DECIMAL instead. Decimals have well-defined behavior for rounding and range overflows...

If you expect method calls in RSpec 3, be aware that the argument matchers use very liberal equality rules (more...

developer.mozilla.org

Text fragments allow linking directly to a specific portion of text in a web document, without requiring the author to...

Most of our applications use CarrierWave for file uploads. CarrierWave has an integrated processing mechanism for different file versions with...

Sometimes we have to write code that behaves differently based on the version of a specific gem or the Ruby Version itself. The version comparison can often be seen with...

...send a merge request, please confirm that your code ... has been reviewed by yourself beforehand fulfills every requirement defined as an acceptance criterion does not have any log or debugging...

Running gem update --system will install the latest version of RubyGems. However the latest version might not be compatible with...

...This is because your app only has a single page load when the user begins her session. After that only fragments are updated and the tag that sends the page view to Google Analytics is probably never evaluated again. Luckily you can fix this. Simple mode: You just want to track all the page views Embed your Google Analytics code as always. Now add the following code snippet: up.on('up:location:changed', function(event) { ga('set', 'page', location.pathname); ga('send', 'pageview'); }); Hard mode: You want more control over what's being tracked First, edit your Google Analytics code snippet and comment out the last line (ga('send', 'pageview')): (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-1234567', 'auto'); // ga('send', 'pageview'); // Don't send the pageview here Now add the following compiler...

Sometimes it is useful to define a named scope by implementing a static method with the scope's name on...

Most of the time it is a tedious task to apply a code style guide to an existing code...

To keep JavaScript sources small, it can sometimes make sense to split your webpack bundles. For example, if your website...

content-security-policy.com

tl;dr The strict-dynamic source list keyword allows you to simplify your CSP policy by favoring hashes and nonces...

...it and just builds a framework for concrete implementations. This is were another gem becomes important: database_cleaner-active_record. It provides the default ActiveRecord cleaner instance and is also...

...second database just once by using DatabaseCleaner[:active_record, db: MigrationRecord], but it's better readable and more convenient in case you want to change a strategy in the future...

...PNG with a decent resolution (72 dpi). However, in my experience the result is better, if you set the density to a higher value and then resize to the desired...

...size. But you can just toy with those values and see what works best for you. convert -density 1200 -resize 96x96 input.svg output.png Transparency By default, your target image is...

We generally use multiple application servers (at least two) and you have to search on all of them if you...

...write <<EOT. If you do this, your terminating sequence must be at the very beginning of the line. It's less pretty and there is rarely a reason to use...

When debugging your application, you will come across objects created by some gem or framework. You don't have the...

New versions of wkhtmltopdf dissallow file:// URLs by default. You can allow them by passing --enable-local-file-access.

You can share a state in Ruby with global variables. Even if you should avoid them whenever possible, for debugging...