Skip to content
Write Software, Well
  • Services
  • Books
  • LinkedIn
  • Archive
  • About
Sign in Subscribe
Stimulus Controller

Practical Stimulus: Building a Counter Component

In this article, we will build a counter component using the Stimulus JavaScript library. This simple example will demonstrate a bunch of useful features of Stimulus such as managing state, handling events, and targeting DOM elements.

Practical Stimulus 4 min read
Useful Features of a Ruby Hash

Ruby's Hash is a Swiss-Army Knife

A Hash is a built-in data structure in Ruby that maps values to keys and has a constant-time O(1) lookup. This article shows the capabilities of this simple, but equally powerful tool. We’ll start with the basics but also cover some obscure but equally useful features of hash.

10 min read
Ruby Standard Library: The Abbrev Module

Abbrev: A Hidden Ruby Gem

The Abbrev module in the Ruby standard library helps you find out all the possible and unique abbreviations for one or more strings. In this post, we'll learn how it works along with a practical example. We'll also take a peek behind the scenes to see how it's implemented.

4 min read
Zeitwerk without Rails

Using Zeitwerk Outside Rails

Did you know you can use Zeitwerk outside Rails? This article shows how to use the Zeitwerk gem to autoload classes and modules in a Ruby app that's not using Rails. We'll also learn how Rails configures Zeitwerk internally and introduce the concept of models in our no-rails Ruby web application.

5 min read
Content Security Policy (CSP) API in Rails

How to Implement Content Security Policy in Rails

This article shows how to implement content security policy in your Rails applications to protect against cross-site scripting (XSS) vulnerability. We'll also learn how you can report CSP violations without enforcing the policy and make exceptions for inline scripts with nonce attributes.

8 min read
You don't need Rails to start using Hotwire

You Don't Need Rails to Start Using Hotwire

Although Hotwire is closely tied to Ruby on Rails, you might be surprised to know that you don't really need Rails to learn, play, and experiment with Hotwire. In this article, we'll build a simple static site that uses Turbo Drive + Frames to make it responsive and use Streams to make it dynamic.

Hotwire 21 min read
Overview of Content Security Policy (CSP)

Content Security Policy (CSP): What Every Web Developer Must Know

This is a comprehensive guide to Content Security Policy (CSP). If you build websites for a living, CSP is an important concept to know, understand, and implement to protect your users from Cross-Site Scripting (XSS) Injection attacks. This post covers (almost) everything you need to know about CSP.

17 min read
Logging in Ruby

Logging in Ruby: (Almost) Everything You Need to Know

Like backups, logging is one of those topics that seems unnecessary until something goes wrong! It's very frustrating to fix a bug that's only reproducible in production without having any logs to help you debug it. This post covers the basics of logging in Ruby and adds logging to our no-rails app.

This article is for Members only

Rails Companion 9 min read
instance_variable_set method in Ruby

How to Dynamically Create Instance Variables in Ruby

This post shows one way to dynamically initialize multiple instance variables in a Ruby class using metaprogramming. If you need to pass multiple, separate pieces of data to a constructor (and cannot refactor the code for some reason), it's a pretty good technique to reduce all the repetitive code.

3 min read
How to Render SVG Icons in Rails

How to Render SVG Icons in Ruby on Rails

This post shows how I render SVG icons in my Ruby on Rails applications. Instead of littering your HTML with complicated SVG tags, keep them tucked away in a folder as an ERB partial, and use a Rails helper to insert it in your views. Result: reusable, customizable icons and readable HTML.

1 min read
MVC Rails - Views

How to Implement Rails-like Dynamic Views in Ruby

In this article, we will learn 'one' way to implement the controller-to-view data handoff using instance variables, just like Rails, and following the same conventions as Rails. Although it's a highly simplified implementation to keep things simple, I hope you'll find it fun and learn something new.

This article is for Members only

Rails Companion 8 min read
Model-View-Controller Pattern

Implementing Rails-like Controllers in a No-Rails App

In its essence, a controller class in Rails is a coordinator. It accepts the incoming HTTP request and builds the data required by the view using the domain models. This post shows a highly simplified implementation of the controller pattern for a better understanding of Rails controllers.

This article is for Members only

Rails Companion 9 min read

Page 9 of 17

Load More Something went wrong with loading more posts
  • Sign up
  • Homepage

© Write Software, Well 2025 - Powered by Ghost