Extracting Options from Arguments in Rails You can safely extract options hash from the end of an argument list using the extract_options! method in Rails. Not only it simplifies the method definition but it keeps the method's API flexible, allowing you to add new options without breaking existing callers.
Redirects in Rails: Manual, Helper, and Internals In this post, we’ll explore how redirects work in Rails: what they are, how to redirect manually, and how the redirect_to method simplifies things. We’ll cover common use cases, security considerations, and even dig into the Rails source to see how redirect_to works under the hood.
Understanding the Render Method in Rails In this post, we'll learn how Rails' render method works and how to use it effectively. From rendering templates, partials, and inline content to JSON and custom status codes, this post explores the different ways to render views from your controllers.
Vibe Learning is Underrated Last week, I used AI to finally learn the basics of QuickBooks and handle my company’s bookkeeping. AI didn’t just help me finish a chore, it taught me a skill I’d been avoiding for years. When used with intent, the modern AI tools can accelerate your learning in surprising ways.
Decoding the Business Layer of Software Announcing a new newsletter where I write about topics beyond Ruby on Rails: running a software services business, freelancing, positioning and marketing for developers, working with AI, hiring and tech recruiting, etc. Business Logic is about everything that happens around writing software, well.
Serving Large Files in Rails with a Reverse Proxy Server If your Rails app deals with large files, let a reverse proxy like Nginx or Thruster serve them. In this post, we'll learn how X-Accel-Redirect (or X-Sendfile) header hands off file delivery to Nginx. We'll also read Thruster’s source code to learn how this pattern is implemented at the proxy level.
Fix N+1 Queries Without Eager Loading Using SQL Subqueries In this post, we'll learn how to use a SQL subquery in a Rails app to eliminate N+1 queries and improve performance. We'll profile a real-world example, showing how to fetch a single record from associated has_many records efficiently without eager loading or excessive memory usage.
Reduce Memory Usage by Selecting Specific Columns As your application grows, so do your database tables. If you keep fetching all columns, those extra fields, especially large text or JSON blobs can quietly eat up a lot of memory. This post shows how to reduce memory usage in your Rails apps by selecting only the columns you need from the database.
Profiling Ruby on Rails Applications with Rails Debugbar This post shows how you can get a better understanding of your Ruby on Rails application performance with the Rails Debugbar, a profiling tool inspired by Laravel Debugbar. It also covers how to spot N+1 queries, reduce object allocations, and optimize SQL queries to improve page load times.
Why You Need Strong Parameters in Rails In 2012, GitHub was compromised by Mass Assignment vulnerability. A GitHub user used mass assignment that gave him administrator privileges to none other than the Ruby on Rails project. In this post, I will explain this vulnerability and how you can use the Rails strong parameters API to address it.
Working with HTTP Responses in Rails In this post, we'll learn how to work with the response object in Rails controllers — from inspecting response bodies and headers to setting status codes and content types. This guide also covers key methods like body, status=, content_type, cookies, and more, with practical examples.
Working with HTTP Requests in Rails Every web application needs to process incoming HTTP requests. In this post, we’ll take a closer look at how Rails handles requests, how you can access the request object in the controller, and some of the most useful methods it provides to gather meaningful data from the request.