RubyMine allows bookmarking lines of code. This is super-helpful when working on a complex problem. I've been using...
We use Sentry to be informed about different kinds of issues. One of the key features is that you are...
Let the following setup: # my_model_spec.rb describe MyModel do it 'perfoms a test' it_behaves_like 'something shared' end # something_shared.rb shared_examples_for 'something shared' do it 'does something'
...a test' is spec/models/my_model_spec.rb[1:1]. The ID of the ExampleGroup created by it_behaves_like 'something shared' is spec/models/my_model_spec.rb[1:2] as it is the second ExampleGroup in the...
In some projects we have issues with flaky tests. The best default is to fix them all. But in some cases it might be a pragmatic way to retry them...
...system's environment specifies. This is usually good enough. To test any timezone-dependent behavior in Chrome, you can change the time zone using the Chrome DevTools Protocol. Example
Be careful when using buttons without a type attribute, since browsers will consider them the default submit button of a...
Detect if a gem has been activated A gem is activated if it is either in the current bundle (Gemfile.lock...
So you are comparing two Time objects in an RSpec example, and they are not equal, although they look equal...
Rails 7.1 added the normalizes method which can be used to normalize user input. It lets you define the fields...
While debugging a SPF record I found spf-record.de to be very helpful. it lists all IPs that are covered by...
Version 1.18.0 of irb introduced a welcome banner. Here is how to disable it, or how to add it to...
When an object is created / updated, various callbacks are executed in this order: before_validation after_validation before_save
A good tool to generate strong passwords and secrets is "apg". You can get it with sudo apt-get install...
...up-data': {...}.to_json } (el, { key1, key2 }) => Type conversion { 'count': '5' } up.element.numberAttr(el, 'count') Best Practices ✅ Do: Use data-* for simple scalar values Use up-data for objects, arrays, and...
Rails has generic error messages you can define in your locale .yml files. You may override those application-wide error...
index 0000000..a51cbad --- /dev/null +++ b/app/models/apple.rb @@ -0,0 +1,9 @@ +class Apple < Fruit + belongs_to :juice, class_name: 'AppleJuice' + + attr_accessor :type + + def to_s + I18n.t(type, scope: 'fruits.apples...
index 0000000..a51cbad --- /dev/null +++ b/app/models/pear.rb @@ -0,0 +1,9 @@ +class Pear < Fruit + belongs_to :juice, class_name: 'PearJuice' + + attr_accessor :type + + def to_s + I18n.t(type, scope: 'fruits.pears...
All browsers implement an event named beforeunload. It is fired when the active window is closed and can be used to display an alert to warn the user about unsaved...
...To trigger the alert, you have to call preventDefault() on the event. Note The beforeunload event is only dispatched when the user navigation makes a full page load, or if...
The linked tool can be used to scan your CI/CD workflows for potential security issues and suboptimal defaults if they...
In order to monitor a Rake task using God your Rake file must write a file with its process ID...
Since Rails 7 you are able to encrypt database information with Active Record. Using Active Record Encryption will store an...
Just like Ruby Gems tag their version releases to the corresponding Git commit, it can be helpful to track production...
In tests, it is sometimes useful to create records with specific ids. On PostgreSQL this can cause problems: Usually, PostgreSQL...
Partials always define a local variable with the same name as themselves. E.g. when you are in _recent_users.html.erb, a local...
ruby-warning adds custom processing for warnings, including the ability to ignore specific warning messages, ignore warnings in specific files/directories...