If your app does not need to support IE11, you can use most ES6 features without a build step. Just...
ActiveModel supplies an errors object that behaves similar to a Hash. It can be used to add errors to a record, as well as to query the record for registered...
...multiple subsequent occurrences of a given character with a single one Use Tap For Better Test Data Setup let(:order) do create(:order, name: "My Order").tap do |order|
You can report CSP violations to a log file. Note that there will be a lots of noise, that is...
Ruby 3.0 introduced a breaking change in how it treats keyword arguments. There is an excellent blog post on the...
When you have two models in a has_many, has_one or belongs_to association, the :inverse_of option in Rails tells ActiveRecord that they're two sides of the...
...same association. Example with a has_many / belongs_to association: class Forum < ActiveRecord::Base has_many :posts, inverse_of: :forum end class Post < ActiveRecord::Base belongs_to :forum, inverse_of...
Redis.current will be removed without replacement in redis-rb 5.0. Version 4.6.0 adds deprecation warnings for Redis.current and Redis.current=: `Redis.current...
Just add the parameter :post to the visit method: visit publish_entry_path, :post
tl;dr Individual transform properties are great because they allow you to write more readable and maintainable CSS, especially when...
...until we know for sure which image version we will need and the solution becomes very simple. Here is a small helper function for your mailer views: def inline!(version...
When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into...
...limits_concurrency configuration. Switch to :solid_queue adapter in your test to verify blocking behavior. Job Configuration class MembershipJob < ApplicationJob limits_concurrency(key: ->(membership) { membership }) end The problem
...is blocked') do membership = create_valid_membership(id: 76381) ActiveJob::Base.queue_adapter = :solid_queue begin MembershipJob.perform_later(membership) second_blocked_job = MembershipJob.perform_later(membership) # Verify blocking behavior assert_equal...
Lightweight Angular JS directive to upload files Includes polyfills for old IEs. Unfortunately, their auto-loading mechanism may not work...
sudo apt-get install sqlite3 libsqlite3-dev sudo gem install sqlite3-ruby
Most web applications contain several examples of state machines, including accounts and subscriptions, invoices, orders, blog posts, and many more...
Splitting a long method into sub methods is easier in instances since it is in classes. Since...
Probably was in the repository once and got deleted in a commit that you pulled.
Programatically invoke Rails generators Require the generator, instantiate it and invoke it (because generators are Thor::Groups, you need...
Look-arounds provide a way to match context-dependant. You can look-behind, look-ahead and to both in a positive and negative way. The look-around will...
...Modifiers in Ruby Add modifiers after the final slash, e.g. /Regex/im, or at the beginning of the regex, e.g. /(?i)regex/. i: case insensitivity m: make the .-character also match...
DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It...
...NonExistentClass".constantize # => NameError: uninitialized constant NonExistentClass Dynamic Programming In scenarios where your application’s behavior depends on dynamic constant resolution, safe_constantize may offer a more convenient control flow to...
I recently encountered this error as I was trying to build assets: $ node esbuild.config.js .../node_modules/esbuild-plugin-browserslist/dist/resolveToEsbuildTarget.js:43 throw new Error('Could...
2013-02-20 (Tobias) ... with exactly the following rows 2012-06-20 (Henning) Better normalization (more consistent for expected/real input, gets rid of nbsps) 2012-06-01 (Tobias)
...wildcard support (partial matches) 2012-05-25 (Tobias) Better error output; "should not see" now fails if any of the rows is present; cells are now matched exactly, wildcard for...
To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...