Rails: Assigning associations via HTML forms
Rails forms can assign tag associations in several ways, from array columns to join models; nested attributes keep tag changes in one transaction.
Rails cache connection settings
Redis cache connections in Rails can be tuned with custom timeouts, reconnect behavior, and error handling to avoid slow cache operations and missed connection failures.
Simple Form: Rendering errors without an appropriate attribute
ActiveRecord base errors do not render in Simple Form by default; they need explicit handling to display form-wide validation messages.
Using Capybara finder methods with arbitrary matching conditions
Capybara matchers and finders can take a Ruby block for extra DOM conditions when built-in options are not enough. Script calls inside filter blocks need a temporary wait time to avoid Selenium timeouts.
Project management best practices: Technical debt summary
Prioritizing refactoring and upgrade work is harder in larger projects; a maintained technical-debt summary helps compare effort, customer value, and developer value.
How not to turn your application into a spam relay
Abused sign-up and password-reset emails can turn applications into spam relays when user input is reflected in messages. CAPTCHAs, rate limits, and avoiding arbitrary text reduce the risk.
JavaScript: Detecting the end of native smooth scrolling
Native smooth scrolling has no built-in completion signal; scrollTo() and scrollIntoView({ behavior: 'smooth' }) do not return promises, so a scroll idle timeout can wait for the animation to finish.
Rails: Rescuing exceptions for specific exception types
Rails can map selected exceptions to non-500 responses and suppress error monitoring noise, such as returning 404 for missing records or denied access.
Using the Truemail gem to validate e-mail addresses
Email address validation inside the app avoids external SaaS dependencies and can catch bad domains before sign-up. DNS-based checks with MX-only lookup balance reliability and safety better than SMTP probing.
Storing trees in databases
Tree data in relational databases can be stored with parent links, paths, nested boundaries, or closure tables; the choice trades write cost against read speed.
Custom RSpec matcher for allowed values (or assignable_values)
Custom RSpec matcher for checking allowed association values, useful when validating assignable_values on model associations.
Beware when using ActiveSupport time and date calculation methods
Duration#ago and Duration#from_now return ActiveSupport::TimeWithZone, which can introduce unexpected timezone behavior when an app assumes local or timezone-unaware dates.
Rails: Overriding view templates under certain conditions only
Use request-specific view paths to swap in alternate templates for selected conditions, with fallback to the default templates when no override exists.
Pretty commit messages via geordi
Generate polished Git commit messages from Linear stories, including issue ID, title, and link, using geordi commit and a .geordi.yml repository config.
A quick introduction to CORS
Cross-origin browser requests need explicit server approval; otherwise the Same-Origin Policy blocks access. CORS uses Origin and Access-Control-Allow-Origin headers, with preflight checks for some methods.
Rails: Your index actions probably want strict_loading
Strict loading in index actions catches N+1 queries when views touch unpreloaded associations, causing test failures instead of hidden database hits.
Rails: How to test the parsed response body
Rails response tests can parse bodies by MIME type with parsed_body, replacing manual JSON.parse(response.body) in many cases and enabling cleaner assertions.
How to exclusively lock file access in ruby
Prevent race conditions when multiple Ruby processes read or write the same file by using flock for exclusive locking, optionally via a companion .lock file.
SASS: Reusing styles from other files
@extend reuses Sass selectors, but multi-file bundling can duplicate imported styles and break the expected selector merging.
How to enable template coverage support for simplecov
Template and eval coverage in Ruby can be tracked with SimpleCov from Ruby 3.2 onward, including Haml and ERB templates.
FactoryBot: Passing attributes to associated records using transient attributes
FactoryBot transient attributes can pass custom values into associated records, letting parent factories build children with dynamic names and flags.
Rails migration: Changing a column type without losing the content
Rails migrations can change column types without dropping data by using custom SQL casting, but rollback may fail when values cannot be converted.
Creating a sample video with ffmpeg
Create tiny test videos with ffmpeg by lowering resolution, framerate, and bitrate to keep files small while preserving duration.
Heads up: Deployment with newly generated SSH key (using ED25519) might fail
Capistrano deployments can fail with ssh-ed25519 keys because net-ssh needs ed25519 and bcrypt_pbkdf; stale host fingerprints in ~/.ssh/known_hosts can also block access.