What is params.expect and how to use it in Rails 8? ruby

What is params.expect and how to use it in Rails 8?

params.expect in Rails 8 replaces require/permit and fixes a real weakness: crafted params like ?user=string used to raise NoMethodError and 500 errors. How the new syntax works, how it handles arrays with precision, and how to migrate your controllers.

Jan 27, 2025

How to write custom RSpec matchers in your Ruby on Rails app ruby

How to write custom RSpec matchers in your Ruby on Rails app

Custom RSpec matchers turn repetitive assertions into readable, reusable specs. Step by step: define a matcher with RSpec::Matchers.define, add clear failure messages, build flexible matchers that take arguments, and wire them into your Rails test suite.

Jan 20, 2025

What's new in Ruby 3.4

What's new in Ruby 3.4

Ruby 3.4 adds the new 'it' block parameter that makes .then chains and maps cleaner than numbered parameters, chilled strings as a step toward immutability, and enhanced Range operations. What each change looks like in practice, with before and after code.

Mastering database enums in Rails with Postgres - Guide

Mastering database enums in Rails with Postgres - Guide

Database enums in PostgreSQL give Rails apps type safety, implicit ordering, and faster queries than string columns. Single-value enums with validation, multi-select enum arrays, dynamic enum management, and the migrations that wire it all together.

How to run Rails console in safe sandbox mode?

How to run Rails console in safe sandbox mode?

Rails console sandbox mode wraps every database operation in a transaction and rolls it all back on exit, so you can experiment safely. How to launch it, plus the traps: database locking, non-rollbackable operations, and why production use still needs care.

How to get table size in PostgreSQL database?

How to get table size in PostgreSQL database?

PostgreSQL table size is more than the data: pg_table_size, pg_indexes_size, and pg_total_relation_size each measure different things. One ready SQL query lists every table with data, index, and total size, sorted by the biggest disk consumers first.

What is Frugal architecture?

What is Frugal architecture?

Frugal Architecture is Werner Vogels' framework for cost-conscious system design: three pillars (Design, Measure, Optimize) and seven laws, from treating cost as a non-functional requirement to continuous optimization, explained with practical examples.

The Truth About Password Security: Beyond Special Characters

The Truth About Password Security: Beyond Special Characters

Password security depends on entropy, not special characters. The math behind entropy = N * log2(R), why length beats complexity rules, why database breaches (not login guessing) are the real threat, and implementation tips for saner password policies.

How to listen to Rails events

How to listen to Rails events

ActiveSupport::Notifications lets you listen to Rails events like transaction.active_record without extra gems. How the instrumentation API works, subscribing to built-in Rails events, and publishing your own custom events for better observability.

Dockerizing NextJS for development - Quickstart guide

Dockerizing NextJS for development - Quickstart guide

Dockerize NextJS development with docker-compose watch: sync ./src into the container, rebuild on dependency changes, and keep hot reload working. A complete docker-compose.yml and Dockerfile you can copy for a reproducible dev environment in minutes.

Streamlining Rails controllers with custom filters

Streamlining Rails controllers with custom filters

Rails controllers bloated with subscription checks? Extract that logic into custom filter classes: a before_action that delegates to a dedicated object, giving cleaner controllers, clearer error messages, easier testing, and a pattern you can expand.

CSS units - which one should be used and when

CSS units - which one should be used and when

CSS units decide how responsive and accessible your site is. A practical tour of px, em, rem, vh, vw and friends: what absolute, relative, and viewport based units really do, plus a short opinionated guide on which unit to pick for fonts, spacing, and layout.

How to deep equal in Javascript?

How to deep equal in Javascript?

Deep equality in JavaScript is trickier than it looks: JSON.stringify fails when key order differs. Compare the real options: the deep-equal package, writing your own recursive check, lodash isEqual, and Node's built-in assert.deepStrictEqual.

What is Turbo Frames in Rails?

What is Turbo Frames in Rails?

Turbo Frames let Rails reload just a fragment of the page instead of the whole thing, with no custom JavaScript. What Turbo Frames are within Hotwire, a practical example of wrapping views in frames, and the responsiveness gains you get almost for free.

Event bubbling in Javascript and React

Event bubbling in Javascript and React

Event bubbling in JavaScript and React: how a click travels from the target element up the DOM tree, what benefits that gives you, and why React does not really bubble events but simulates them with its synthetic event system.

What is THIS word in Javascript

What is THIS word in Javascript

What 'this' means in JavaScript: why its value depends on how a function is called, how setTimeout callbacks break your assumptions, and how bind, call, and apply put you back in control, shown with simple Dog and Cat examples.

Event Loop in Javascript with examples

Event Loop in Javascript with examples

The JavaScript event loop explained with examples: how the single-threaded call stack executes tasks, where Web APIs take over timeouts and API calls, and how the event loop decides what runs next in the non-blocking I/O model.