Kamal Tip - Private Network only Database Server

Edit: In the original version of this post I made a mistake. This post has been corrected. See the details at the below for an explanation of the mistake and the solution. Mistake Summary & Solution In the original version of this post I had stated that the App servers IP in the Kamal configuration should be set to it’s public IP. This is incorrect. With the SSH proxy pointing at the public IP as well, this resulted in a jumphost connection problem, meaning it tried to connect to the public IP through a proxy of the public IP. This obviously didn’t work and resulted in inconsistent behavior with Kamal. The solution was to replace the App servers IP address to be the private IP instead. As a result, the only place the public IP of the server is referenced is in the Kamal SSH proxy configuration. ...

November 22, 2024 · 7 min · JD

State Design Pattern

Manging the state of objects and state specific behavior is always an interesting problem to deal with. The Rails community has done a great job of developing libraries to help manage this. Most of these libraries come in the form of State Machines. These typically have the pattern of defining states, events to change states, and constraints by which those states can or cannot change. Usually, this code is maintained in your model, and in some cases states can have their very own model and DB table and keep an audit history of some kind. ...

June 8, 2021 · 7 min · JD

Double Polymorphic Associations in Rails

Polymorphic associations is a common theme among many applications. Things can get complicated, especially as far as naming is concerned, when you consider having a double polymorphic association. Rails provides all the necessary mechanisms by which to manage this in a way that makes sense for most business needs as well as leaving it readable for future programmers that come by in the future. In programming languages and type theory, polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types. ...

May 31, 2021 · 3 min · JD

Resolving client side routes in Rails

There’s a quick and easy way to satisfy client side routing in a Rails application. Rails will automatically try to resolve it’s routing on the server side and throw an immediate 404 if no valid pages exist. Since my main application at work is a React SPA I needed a way to resolve routes to the client and not let them get caught by the server and throw a 404. The (/*path) method route ‘helper’ allows through any route so it can then be handled elsewhere. ...

January 9, 2021 · 2 min · JD