...so I hope it will be fixed with a future release. The following test succeeds: context 'factories' do let(:test_case) { FactoryBot.create(:test_case) } it 'are valid' do expect(test...

...byebug) FactoryBot.create(:test_case) *** NameError Exception: uninitialized constant # ::TargetLimitation Did you mean? TargetsTestScenario It seems like Byebug does not work well with zeitwerk. There is already a patch in Ruby...

WProofreader is a spelling and grammar checking tool that integrates with textareas and numerous WYSIWYG editors. While it usually activates automatically, depending on your application, it may fail to boot...

...do that ourselves, so we disable it autoDestroy: true, lang: 'de_DE', serviceId: '...', // ... } Ensure https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js is loaded as described in the docs. To activate WProofreader, you can now...

workingdraft.de

The robots.txt file and HTML tag can be used to control the behavior of search engine crawlers. Both have different effects. robots.txt Marking a URL path as "disallowed" in robots.txt...

...crawlers to not access that path. robots.txt is not a guarantee for exclusion from search engine results. A "disallowed" URL might be known from an external link, and can still...

...language when they visit the root path. Here is how to do it without a server-side component (like a Rails application). Use JavaScript's navigator.language (real browsers and IE11...

...following JavaScript will try to auto-detect a user's preferred language. It understands strings like like de_AT, and if the user prefers neither of your supported languages it...

github.com

...dependencies and database types. Here's what Gemika can give your test's development setup (all features are opt-in): Test one codebase against multiple sets of gem dependency sets...

...currently MySQL or PostgreSQL). Compute a matrix of all possible dependency permutations (Ruby, gem set, database type). Manually exclude incompatible dependency permutations (e.g. Rails 5.0 does not work with Ruby...

...links. Popular pagination libraries like will_paginate or Kaminari do this for us by simply issuing an extra query, like this: SELECT post.* FROM posts LIMIT 20 OFFSET 100;

...of the time. But rarely, you might have very complicated WHERE conditions or a subquery that takes time to run. In these cases, doing two queries is slower than it...

...Ever wanted to give an element "the container's width minus 20px on each side"? Here you go: .foo { width: calc(100% - (20px * 2)); } When using Sass, you need to...

...interpolate Sass expressions: $margin: 20px * 2 .foo width: calc(100% - #{$margin}) Supported by all modern browsers and IE9...

github.com

When using Sidekiq in your application, you must write thread-safe code. This wiki page also lists gems that are known to be unsafe on threaded applications.

...gem that will also be used by a Sidekiq worker, make sure to confirm it's thread-safe...

In Capistrano 2, directories in shared_children used to be symlinked to the shared directory during the finalize_update task. # /lib/capistrano/recipes/deploy.rb _cset :shared_children, %w(public/system log tmp/pids) # ... task :finalize...

...update, :except => { :no_release => true } do # ... shared_children.map do |d| run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}" # <-- symlinks only the last segment here end # ... end This would symlink...

...could also use Haml instead. Example Consider the following helper. def greeting message = ''.html_safe message << 'Welcome to ' message << content_tag(:span, Rails.env, class: 'greeting--location') content_tag :div, message...

...That looks clumsy and is hard to read. Wouldn't it be nicer to say something like this? def greeting render_haml <<-HAML .greeting Welcome to %span.greeting--location = Rails.env

api.jquery.com

jQuery offers many different methods to move a selection through the DOM tree. These are the most important: $element.find(selector) Get the descendants of each element in the current set...

...of matched elements, filtered by a selector. Does not find the current element, even it matches. If you wanted to do that, you need to write $element.find(selector).addBack(selector...

stackoverflow.com

...that whenever you are using those values for database interaction, you'll end up scoping on the wrong records since the database representation of these dates is not converted to...

Use form models to handle this problem Or soften the validation to validates_presence_of :parent Usually you would validate presence of parent object id, like in this...

validates_presence_of :parent_id # <- end With the parent already persisted creating nesteds still works fine. But one will encounter a 'parent id missing' error on creating a parent...

...You can add other AWS account depending files like .fog or .guignol.yml too. Create symlinks for some config files like .aws_credentials and .fog: ln -s ~/.aws/.aws_credentials ~/.aws_credentials

...export EC2_CERT=~/.aws/cert-ec2.pem export AWS_CREDENTIAL_FILE=~/.aws/aws-credentials Perhaps you also want to set a default region and the JAVA_HOME: export EC2_REGION=eu-west-1

Say you have an RGBA color that you need as a non-transparent color because of reasons. Basically, this is possible. Just understand that you will convert your RGBA color...

...your background is white, so you'll use #fff as that for examples below. Simple approach When your know the RGBA color's base RGB color (e.g. your brand color...

In specs, the session never persists but is always a new object for each request. Data put into the session in a previous request is lost. Here is how to...

...circumvent that. What's going on? You are making ActionController::TestRequests in your specs, and their #initialize method does this: self.session = TestSession.new This means that each time you say something...

...message like this, rubygems.org might have issues with their ipv6 connectivity: $ bundle install Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch...

...specs from https://rubygems.org/ due to underlying error <timed out (https://rubygems.org/specs.4.8.gz)> The (a little bit dirty) possible solution If that's actually the case, then you can try...

Rails 5.2+ supports "verbose query logs" where it shows the source of a query in the application log. Normally, it looks like this: User Load (0.5ms) SELECT "users".* FROM...

...app/controllers/users_controller.rb:42:in `load_users' However, you may encounter ActiveRecord's LogSubscriber as the source for all/most queries which is not helpful at all: User Load (0.5ms) SELECT "users...

github.com

Barby is a great Ruby gem to generate barcodes of all different sorts. It includes support for QR codes via rQRCode; if you need to render only QR codes, you...

>> Barby::Code128.new('Hello Universe').to_image.to_data_url => "data:image/png;base64,iVBORw0KGgoAA..." For super-crisp barcodes, render them as SVG. Printing images usually causes some level of blur...

jQuery doesn't store information about event listeners and data values with the element itself. This information is instead stored in a global, internal jQuery cache object. Every time you...

...gets deleted is when you call remove() on the element that put it there! Since cache entries also have a pointer back to the element that spawned them, it is...

...should), the host's IP address is: 10.0.2.2 You'll need it to access shared folders or your host's web server when testing pages in IE.

What are the advantages of a gem like memoized over the @variable ||= syntax? Why can it be dangerous to memoize class methods? Why is it often fine to...

...memoize instance methods? Resources Speeding up Rails with Memoization 4 Simple Memoization Patterns in Ruby (And One Gem) Don't use the || operator to set defaults Exercise

When you need to check a value for presence, don't rely on JavaScript since it considers 0 or "0" false. Also don't rely on LoDash's _.isEmpty:

While the name implies that it's meant only for collections, you probably still want something like isBlank or isPresent that return true/false for objects humans would normally consider...

Accessing pseudo elements via JavaScript or jQuery is often painful/impossible. However, accessing their styles is fairly simple. Using getComputedStyle First, find the element in question. let element = document.querySelector('.my-element...

...s getComputedStyle. It takes an optional 2nd argument to filter for pseudo elements. let style = window.getComputedStyle(element, '::before') let color = style.getPropertyValue('background-color') The returned color will be a string...