Write Software, Well

Experience the joy of programming in Ruby and building web applications with Rails and Hotwire.
https://www.writesoftwarewell.com/ (RSS)
visit blog
How a Ruby Method Becomes a Rails Action: Part One
4 Jan 2025 | original ↗

In this post, we will explore how a simple Ruby method, when added to a controller, becomes an action in Rails, ready to process incoming HTTP requests and send responses. We'll also trace the path of an incoming HTTP request to a Rails controller action.

Using Hotwire for Inline Form Updates Without Form Submission
12 Nov 2024 | original ↗

Sometimes you need dynamic content on the form, where parts of the form update based on the user input. This post shows how to use Hotwire's Turbo and Stimulus libraries for in-place form updates by loading data from the server, without submitting the form, which happens only once, at the end.

A Brief Introduction to Rails Initializers: Why, What, and How
19 Oct 2024 | original ↗

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.

Not-Null Shortcut in Rails 8 Migration Generator
7 Oct 2024 | original ↗

Rails 8 lets you mark a database column as not-null by appending an exclamation mark after the column while generating a migration. It's a nice quality of life improvement. This post also contains a few things I learned after reading the pull request.

If You're a WordPress Developer, Learn Ruby and Rails
26 Sept 2024 | original ↗

With the recent WordPress drama, many developers might be concerned about its future. While WordPress isn't likely to go away, now might be the perfect time to invest in learning other tools and technologies. I suggest Ruby on Rails - you won't regret it!

How to Count the Number of Commits After a Specific Commit in Git
25 Aug 2024 | original ↗

Counting the number of commits after a specific commit in Git is a common task when you make small but frequent commits and need to squash them before rebasing from the main branch. This post shows one simple way to do this in git. Let me know if you know a better solution.

The Rails Router Handbook
8 Aug 2024 | original ↗

For the past few days, I've been trying to learn everything I could about the Rails router. I compiled all of my notes together with the past articles on this blog, and published a handbook on the router. I hope you find it useful and you learn a thing or two about the incredible Rails Router.

Routing Concerns in Rails
7 Aug 2024 | original ↗

You must have used concerns in Rails. Did you know you can also use concerns for your routes? They allow you to declare common routes to be reused in other resources and routes. This post covers the basics of routing concerns, including what they are, how they work, and when you might need them.

Understanding Shallow Nested Routes in Rails
6 Aug 2024 | original ↗

Shallow nesting lets you avoid deep nesting by generating the collection actions scoped under the parent, but by not nesting the member actions.

Working with Resourceful Routes in Ruby on Rails
2 Aug 2024 | original ↗

The concept of resourceful routing took me a long time to understand, but once it clicked, it changed how I viewed web applications. This post covers the basics: what a resource is, the routes it generates and how resourceful routing provides a nice organizational structure your Rails applications.

How to Route an Incoming URL to a Rack Application in Rails
29 Jul 2024 | original ↗

The Rails router can dispatch an HTTP request to a Rack endpoint, either in your application or within a gem. This is useful when you want to provide a well-isolated web UI or front-end to the users of your gem. In this post, we'll learn why you may want to do this, how it works, and how to do it.

Map a Resourceful Route in Rails to Another Controller Class
29 Jul 2024 | original ↗

If you want to map a resourceful route to another controller class in Rails, you can do so by passing the controller option to the resources method.

Working with Nested Resources in Ruby on Rails
22 Jul 2024 | original ↗

Rails allows you to nest a resource within another resource to express the logical relationship between them. This post shows how nested resources work in Rails.

How to List and Filter Routes in Ruby on Rails
18 Jul 2024 | original ↗

You can list all the routes in your Rails application by running the `bin/rails routes` command in the terminal. or by visiting `/rails/info/routes` path on a running Rails application.

Understanding the Match Method in Rails Router
15 Jul 2024 | original ↗

In this post, we will learn about the match method, which forms the core of the Rails router. We'll also explore how the match method works behind the scenes. Once you really understand the match method and its options, the rest of the routing methods and shorthands become very easy to understand.

How to Override the Named Route Parameter ID in Rails
12 Jul 2024 | original ↗

This post shows how you can override the default named parameter :id in Rails, by overriding the `to_param` method on the Rails model.

↑ These items are from RSS. Visit the blog itself at https://www.writesoftwarewell.com/ to find everything else and to appreciate author's digital home.