Skip to content
Akshay's Blog
  • Archive
  • About Me
Sign in Subscribe
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.

Ruby no Rails 10 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
Rails Initialization Sequence

A Brief Introduction to Rails Initializers: Why, What, and How

At first glance, Rails initializers seem complex, but they're solving a simple, but important problem: run some code after framework and gems are loaded, to initialize the application. This post covers the basics of initializers, including what they are, how they work, and how Rails implements them.

Rails Internals 7 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 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.

Ruby no Rails 7 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.

Ruby no Rails 7 min read
Binding in Ruby

Understanding the Concept of Binding in Ruby

Binding is an elegant way to access the current scope (variables, methods, and self) in Ruby. Typically, you use it for building view templates and executing strings of Ruby code. The Ruby REPL also makes abundant use of binding. In this post, we'll learn what binding is and how it works.

4 min read
Build Your Own Router

Build Your Own Router in Ruby

Have you always wondered what a Router is and how it works? I know I have. In the third article in the series on building a web application in Ruby without Rails, we'll build our own router to get a deeper understanding and appreciation of the Rails Router.

Ruby no Rails 10 min read
Serving static files and dynamic views in Ruby

Let's Build a Webapp in Ruby without Rails: Serve Static Files and Render Dynamic Views

This is the second article in the series where we build a simple, yet complete web app in plain Ruby, without using Rails to better understand how Rails works. In this article, we'll learn how to serve static files and use the ERB gem to render dynamic views. All in plain Ruby, without using Rails.

Ruby no Rails 10 min read
A rack-compliant web application in Ruby

Let's Build a Web Application in Ruby without Rails

Rails is great for building web apps. But it can be quite overwhelming if you don't know how web applications work. In this series of articles, we'll build a simple but complete app in plain Ruby without Rails, to get a deeper understanding and appreciation of everything Rails does for us.

Ruby no Rails 10 min read

Page 2 of 11

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

© 2023 - Akshay's Blog