The way Rational#to_s works on Ruby has changed from Ruby 1.9 on. Here is how to get the...
When working with file uploads, we sometimes need to process intrinsic properties like the page count or page dimensions of...
To attach files to your records, you will need a new database column representing the filename of the file...
It's 2024 and we have tools like ffmpeg, imagemagick and GPT readily available. With them, it's easy to...
Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background
def store_new_password # ... end end Write classes for parameters that belong together Sometimes you see multiple functions that always use the same parameters. This often happens if...
Sometimes you'll find yourself with a set of tasks that require similar code for different models. For example, if...
When your model is using a callback like before_save or before_validation to calculate an aggregated value from its...
CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these...
Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of...
Below is a strict, but still workable Content Security Policy for your Ruby on Rails project. Use this CSP if...
Looking at the source code of the validates_numericality_of validator, it becomes clear that it converts the attribute in...
In order to have monitoring for Sidekiq (like queue sizes, last run of Sidekiq) your application should have a monitoring...
Every modern Rails app should have a Content Security Policy enabled. Very compatible default The following "default" is a minimal...
When putting phone numbers into web pages, you should use tel: links so smartphone users can click those numbers to...
Let's say we have posts with an attribute title that is mandatory. Our example feature request is to tag...
How to get a backtrace from a running Ruby process: Ruby 2.6 # First, find out the PID of your Ruby...
get_route_with_tokens first_etag = get_etag get_route_with_tokens second_etag = get_etag expect(second_etag).to eq(first_etag) end it 'sends different...
...get a different ETag for a different user session reset_session get_route_with_tokens second_etag = get_etag expect(second_etag).to_not eq(first_etag) end end
If you want to prevent that two processes run some code at the same time you can use the gem...
GoodJob and ActiveJob rescue exceptions internally, preventing exception_notification from triggering. This can cause silent job failures.To get notified, subscribe...
Nokogiri is great. It will even fix invalid HTML for you, like a browser would (e.g. move block elements out...
When storing files for lots of records in the server's file system, Carrierwave's default store_dir approach may...
Sometimes you need to remove high Unicode characters from a string, so all characters have a code point between 0...
HTTP header values must only contain low-ASCII (7-bit) characters for safe transport. From RFC 7230: Historically, HTTP has...