ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use...
...for Structs are temporary data structures which just hold state and don't provide behaviour. In many cases you could use a simple hash as a data structure instead. However...
...are incredibly fast. If you have to handle lots of data it may be better to use hashes for performance reasons, even if the readability of the code suffers compared...
When deleting a record in your Rails app, Carrierwave automatically takes care of removing all associated files. However, the file...
...to determine if a service can be restarted or not. To manipulate the default behaviour, the package policy-rcd-declarative-allow-all or policy-rcd-declarative-deny-all can be...
...in an encrypted YAML file. Usage is simple: each key in the credentials file becomes a method on Rails.application.credentials, returning the corresponding secret. # Credentials file file_storage_secret: superstrongsecret
How can I configure virtual IP's? There are two parameter to set up virtual ips in Keepalived: virtual_ipaddress...
We have now updated/created two gems that implement the requirements above using the best practices we know of: assignable_values: ActiveRecord macro to restrict the values that may be...
...for all exceptions (previously true) :none: It will raise for all exceptions (previous default behavior, value false) Using the new default needs to change a RSpec test like this:
available for button, fieldset, input, select, textarea, command, keygen, optgroup, option Browser specific behavior: IE 11: text inputs that are descendants of a disabled fieldset appear disabled but the...
It's 2024 and we have tools like ffmpeg, imagemagick and GPT readily available. With them, it's easy to...
...move elements to the back (e.g. background images, gradients etc). They will be rendered behind all other elements within the context (e.g. text), but not behind elements outside the stacking...
Deep dive Okay, so the example above has at least one obvious benefit: You do not have to put self.table_name_prefix = "universe_" into each of your classes...
...it. It's not read at all. Here is why (follow links for a better understanding): An ActiveRecord class will pick the table_name_prefix of any of its module...
CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these...
...built into RSpec. Play with some of these matchers in your MovieDB tests. The benefits of using better matchers Which of the following two lines is better? Why?
...is often to prefer isolated tests where possible, but share test setup when it becomes excessively complicated or expensive. If we share setup, it is best to do within a...
...feature of Bundler. It might be an unintended side effect of something else. I believe this command will try to update GEMNAME and GEMNAME only. If this leads to unmatched...
...or newer versions for these libraries before you start. Maybe you can upgrade them beforehand which makes the migration easier. Here are some libraries that I had come across:
...implement the navigation on your own. Tip: Add a feature for your navigation bar beforehand and test links and their highlighting (don't forget dropdown submenus!). After upgrading to Bootstrap...
Today I learned that you can animate HTML elements using the Web Animation API's method .animate(keyframes, options) (which...
The value of the Unicode byte-order character placed at the beginning of the file (BOM). The value given by the charset attribute of the Content-Type...
...a feature look and feel). Frequent deploy gets changes to users faster. We sleep better, because we know stuff still works. Make sure no one removes a feature by accident...
...application changes. The more tests you already have, the less useful an additional test becomes ("Diminishing returns"). Tests sometimes fail even though the code is fine, especially when the test...
Rails default config uses the ActiveSupport::Cache::NullStore and disables controller caching for all environments except production: config.action_controller.perform_caching = false...
Ever needed to migrate data between Redis instances? Give RIOT - Redis Input/Output Tools a try. It supports migration to different...
...diam nonumy eirmod tempor. | | | | | | | | | | | | | | | | | | | +------------+-----------------------------------------+ | Footer | +------------------------------------------------------+ Here are some more details how the layout should behave: Give each element (header, sidebar, etc.) a distinct background color to see where boxes start...
...do not use them. Pay attention to the margins in your styles. Elements that belong together logically (e.g. two navigation sections) should be closer to each other than elements that...
...would possibly need in a clean way, I prefer to simply always use them. Behind the scenes, Open3 actually just uses Ruby's spawn command, but gives you a much...
Open3.capture3 Basic usage is require 'open3' stdout_str, error_str, status = Open3.capture3('/some/binary', 'with', 'some', 'args') if status.success? # okay else raise "did not work" end Open3 will raise...
TL;DR Append your locale keys with _html to have them marked as html_safe and translate them with = t...