Getting an entire test suite green can be a tedious task which involves frequent switches between the CLI that is...
...with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code they're referring to, restate the obvious, or...
...a comment, prefer improving the code: use descriptive variable/method names, extract more variables/methods to better describe what is happening, have a simple structure. However, there are things code cannot express...
...instead of downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a...
...s Fontsource details page for available settings. Why? Using an NPM package has some benefits over placing fonts into your repo: All font weights and glyphs are included.
...future we will be able to transition to display: none by using the transition-behavior: allow-discrete property. This will delay the display change until the transition ends. This is...
CSS transitions are a simple animation framework that is built right into browsers. No need for Javascript here. They're...
end end def allowed_mime_types %w(image/jpeg image/png) end end This will behave like the solution before: User#portrait will get an expected error message and the User...
I often see the use of || to set a default value for a variable that might be nil, null or...
...Yourself (or DRY). In Ruby on Rails we keep our code DRY by sharing behavior by using inheritance, modules, traits or partials. When you reuse behavior you want to reuse...
...module that you include in the Cucumber world. This way the module's methods become available to all step definitions. Think of it as enhancing your Capybara API with app...
Starting with Ruby 1.9, most #each methods can be called without a block, and will return an enumerator. This is...
Background information about session storage in Rails Rails has a default mechanism to store the session in the CookieStore. This...
Ruby (business logic) HTML fragments (layouts and views) CSS/Sass/SCSS (styles) JavaScript (client-side behavior) Static media (images, fonts, videos) Except for the Ruby part, all these files are shipped...
...frees you from needing Webpack and Yarn. This is an experimental solution that could become the default in future Rails versions. It lacks any transpilation/transformation and bundling features. They reason...
...from using fixtures over FactoryBot, as fixtures load essential test data upfront at the beginning of the testsuite. Finding peace with fixtures While setting up the database upfront challenges the...
...idea of maintaining a perfectly clean database state at the beginning of each test, with some disciplined practices, handling fixtures becomes quite manageable. Let’s dive into how this works...
You can use mail-tester.com to check your application's e-mails for issues that might cause e-mails to be...
...hard to understand, the helpers available differ for different versions of Rails and the behavior is subtly different. Make sure you read and understand the API before using these...
A general overview about why and how we migrate can be found under Migrating from Elasticsearch to Opensearch
...and perform the following exercises. Tip If you've forked your MovieDB in the beginning, Jasmine is already integrated in your code base. Movie counter In Working with the DOM...
Expecting a primitive value as an argument to a method invocation is easy: expect(object).to receive(:foo).with('arg1...
...styles from the document. See Styling a Web Component for this case. Applying JavaScript behavior to new elements All client-side JavaScript frameworks comes with mechanisms to activate JavaScript behavior...
...a framework mechanism you may use customElements.define() to register your custom element's JavaScript behavior with the browser directly. A big advantage of using the browser's customElements.define() is that...
When MySQL refuses to use your index, there's a number of things that you may be doing wrong. One...
When your code does not behave as expected, you can use a debugger statement ("breakpoint") at any point in your code. This statement will open a REPL ("console") that you...
...the exact line in the code where your expectation does not match the actual behavior. Since we use open source for everything, we can always find that line. When you...
You can use the config.x configuration in combination with config_for to configure global settings for your Rails 4.2+ application...
...changes it for the current repository. Since it's hard to remember which project behaves how, you should find a suitable global setting. Regardless which option you use you can...
...current branch. Caveat with current For most of us, current is the safest push behavior. However, it has a small side effect: When a branch with your local name does...
It is just not worth the risk and you can always do better. Alternatives Instead, you should take a different approach. Here are several alternatives.
Note The maintenance mode is enabled on all application server as soon as the file /public/system/maintenance.html is present. Installation