...DSL to define new routes. A big drawback however is that your code often becomes much harder to read. Another con of DSLs is that they tend to be so...

...email => 'foo@bar.de' } book.tobias_kraze # => { :phone => '67890', :email => 'bam@baz.de' } Now change Addressbook so each contact becomes their own Contact instance which responds to #phone and #email: book.henning_koch # => Contact<#....> book.henning_koch.phone...

makandra dev

There are several tools for DNS debugging which offer you more or less information. Most of the time the more...

This is a small example on how you can check if your Postgres index can be used by a specific...

Why do we migrate? Due to a change in licensing, we cannot provide Elasticsearch versions >= 8.0. Version 7.17.x will...

Learn to treat files as an ActiveRecord attribute type, like :string or :integer Research Look at the README for...

thegnar.com

...instead of using a more costing feature spec. This is especially useful because they become quite convenient when used with Capybara::Node::Finders and Capybara::RSpecMatchers. This allows to wirte...

...view might be too isolated, since view-specs will mock a lot of rails behavior and render the view independent from the controller-logic. Therefore it will be more applicable...

The recommended additional setup of the spreewald gem, a useful set of cucumber steps, includes adding a file for defining...

If you're responsible for gatekeeping in a projects, here is a guide, what to do. In order to reduce...

Sometimes you need to remove high Unicode characters from a string, so all characters have a code point between 0...

...requestAnimationFrame can be used to reduce the number of repaints for animations. This might benefit your application performance. Read Don't throw exceptions from async functions What Color Is Your...

...helperFunction? What happens when you remove the await of init? What causes the new behavior? Now have a look at this sketched usage of asynchronous functions: const news = await fetchNews...

Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of...

When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...

It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...

While it might be tempting to set it per project (other devs might benefit from it), you need to do it each time for every project "pollute" a project...

linux.die.net

You can convert git commits into patch files. Those can be used to apply to a different repository [1] or...

This still relies on params[:id] existing, so your code should reflect that: # Better User.find(params.expect(:id)) # Or User.find(params.require(:id)) Avoiding issues with extra parameters Rails logs extra...

...should still use permit (or expect) to receive Strong Parameters, but strip extra parameters. # Better (option 1) redirect_to users_path(params.slice(:query, :encoding).permit(:query, :encoding)) # Better (option...

Resources Rails Guide: Internationalization API Guide to localizing a Rails application Locale-aware helpers in ActionView::Helpers::NumberHelper

When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default...

...never influence each other On a similar note, we don't want tests to behave differently based on their execution order or parallelism. One core mechanism in this regard is...

...give your Movie model a #person attribute. Instead, use FactoryBot's transient attributes and before/after hooks to implement the factory above...

When you want to group rails models of a logical context, namespaces are your friend. However, if you have a...

geekytidbits.com

To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...

makandra dev
github.com

...rendering quality is now fine in recent versions of wkhtmltopdf (0.12+). You will never beat LaTeX if you need perfect font rendering. If you are observing strange behavior when including...

...might experience that your application "locks up" whenever you request a .pdf route. This behavior is caused by a deadlock: The Rails process is trying to render the page to...

api.rubyonrails.org

ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use...

You cannot use Array#join on an array of strings where some strings are html_safe and others are not...