Nested ActiveRecord transaction pitfalls
Nested ActiveRecord transactions can hide inner ActiveRecord::Rollback exceptions or fire after_commit callbacks too early, depending on joinable: false and requires_new.
Capybara: Find an element that contains a string
Capybara can locate DOM nodes by text content using text: with a selector or regular expression, avoiding unsupported CSS string-matching selectors.
Always convert and strip user-provided images to sRGB
User-uploaded images can lose correct colors if metadata is stripped before color conversion. Converting to sRGB and reattaching the profile keeps browser rendering consistent.
Ruby: How to determine the absolute path relative to a file
Use File.expand_path with __dir__ or __FILE__ to build file paths that stay correct regardless of the caller’s working directory.
Using ngrok for exposing your development server to the internet
Temporary public access to a localhost development server is useful for testing on another device or through TLS without port forwarding or self-signed certificates.
makandra cards: A knowledge base on web development, RoR, and DevOps
Internal knowledge base with best practices for web development, Ruby on Rails, DevOps, and trainee programs, used by developers worldwide to find practical solutions and learning paths.
Rails: Using require and permit for attributes
Stricter strong parameters raise missing and unpermitted attribute errors during development and tests, helping catch bad requests earlier while requiring environment-specific handling in production.
Unpoly + Nested attributes in Rails: A short overview of different approaches
Rails nested attributes become cumbersome with dynamic subrecords; Unpoly enables friendlier add/remove workflows without losing server-side validation and form helpers.
Collect all values for a given column in an ActiveRecord scope
Retrieve all values from one ActiveRecord column without instantiating records; pluck, ids, and distinct return arrays efficiently, with collect_column for older Rails.
Testing ActiveRecord callbacks with RSpec
Database-backed RSpec checks for ActiveRecord lifecycle behavior are more reliable than stubs when verifying side effects like automatically creating associated records.
Bookmarklet to generate a commit message for an issue in Linear.app
Issue-linked commit messages need a ticket ID prefix; a bookmarklet can prefill the correct [ID] title format from a Linear issue view.
Bash: Build and execute command lines on the fly with "xargs"
Pipe input into commands to avoid manual argument handling; xargs builds command lines from STDIN for batch execution and scripting.
JavaScript basics tutorial: 33 Concepts Every JavaScript Developer Should Know
JavaScript fundamentals often hide bugs in scope, this, prototypes, async flow, and type coercion. Core concepts support cleaner code and fewer runtime surprises.
Regular Expressions: Quantifier modes
Greedy, lazy, and possessive quantifiers change regex matching behavior and performance; poor choices can trigger heavy backtracking or even denial-of-service bugs.
Rails: Comparison of assignable_values and Active Record enum types
Rails enum attributes store states as integers or database enums, with validation and generated scopes; assignable_values still offers conditional rules, associations, and array support.
Ruby: Following redirects with the http gem ("httprb")
Automatically following HTTP redirects with http is optional and limited by max_hops; redirect loops raise an error.
ActiveRecord: String and text fields should always validate their length
String and text columns need model length validation to prevent database exhaustion and avoid runtime SQL errors on oversized input.
Test your application's e-mail spam scoring with mail-tester.com
Check outbound mail for spam filters and deliverability issues with mail-tester.com; a score around 9/10 is usually fine, while plain-text bodies and proper DNS help avoid false positives.
Insomnia helps you querying your API
GUI client for testing and communicating with APIs; a less cluttered alternative to Postman and cURL, available via snap or Ubuntu packages.
Postgres: DISTINCT ON lets you select only one record per ordered attribute(s) for each group
PostgreSQL DISTINCT ON keeps one ordered row per group, useful for latest-per-user queries and other group-wise maximum results when plain DISTINCT is not enough.
Invoices: How to properly round and calculate totals
Invoice totals can miss cents when rounding is done too late or with floats; rounded item totals and BigDecimal keep net, VAT and gross consistent.
How to negate scope conditions in Rails
Finding the opposite of an ActiveRecord scope is tricky with NULL values and older Rails versions; invert_where, subqueries, or Arel can negate conditions safely.
MySQL: Careful when using database locks in transactions
MySQL snapshot reads in REPEATABLE READ can hide concurrent changes, so counts and updates drift unless locking starts before the first query.
Rails: Different flavors of concatting HTML safe strings in helpers
Different ways to build HTML-safe markup in Rails helpers affect readability, buffering, and XSS safety. concat, safe_join, capture, and html_safe each behave differently.