#Ruby On Rails

Archive of blog posts tagged with "ruby-on-rails"

  • June 4 2024

    Form Objects in Ruby on Rails

    As a Ruby on Rails developer, you've likely come across situations where forms don't map directly to a single model or models that have complex validation and business logic. This is where a Form Object design pattern comes in! It encapsulates all the logic related to form processing, validation, and data persistence. It acts as an intermediary between the Controller and the Model. Form Objects offer numerous benefits such as encapsulation of form logic, handling composite forms, implementing custom validations, delegating data persistence, and re-usability of logic across different parts of the application.

  • April 15 2024

    Add taggable support to my personal blog

    In today's post, I discuss enhancing my blog's tag support, moving from a simple comma-separated list to a more powerful and dynamic queryable system using the Ruby gem 'acts-as-taggable-on'. I illustrate the process of installing and migrating the gem with MySQL. I then detail the code for tagging in the Blog model, updating blog forms and controllers. It's crucial to migrate existing tags to the new system, which I did using Maintenance Tasks, including tips for covering edge cases in the tests for the task. Updating existing tests for the blog model to incorporate the new taggable system was the final step. Future considerations include creating a Stimulus Controller for auto-suggested tags and extending this functionality to the Project model.

  • March 9 2024

    Managing Jumpstart Pro Updates

    Jumpstart Pro is a Ruby on Rails SaaS template that streamlines the creation of business-ready web applications, eliminating the need for repetitive coding and configurations. Despite its numerous advantages, maintaining the software can become complex or tedious as applications grow - primarily due to merge conflicts during updates. I share a few strategies I employ to simplify this process, including removing files from the git index that don't require updates, regenerating files like yarn.lock and Gemfile.lock, and refraining from altering core Jumpstart files. I also use a script post-merging to automate the regeneration of these files. These methods have significantly eased the application of Jumpstart Pro updates for me, and I believe they could be beneficial to other developers as well.

  • September 6 2023

    Turbo Will Call Stimulus `connect()` Twice

    When you click a link to return to a page, or use your browsers back button to return to a page Turbo will render a cached preview of the page. It will then fetch an updated version of the page.

  • March 3 2023

    How To Use Docker Compose Effectively as a Development Tool

    In this article, I explore how Docker Compose can simplify software development, using Ruby on Rails as an example project. Docker Compose simplifies the setup and teardown of a project, reduces inconsistencies in development environments, and makes it easier to add ancillary services such as database and caching servers. I demonstrate this by creating a new Rails project, setting up a docker-compose.yml file, and adding services like PostgreSQL and Redis. Once done, I run and develop the new application in Docker. This process eliminates the need to juggle multiple versions of tools and services on a workstation, minimizes bugs caused by different development environments, and conserves resources. I also share insights on how to clone the example repo, create a new project, add the first service to Docker Compose, and develop the application in Docker.

  • February 3 2023

    Running Ruby on Rails on Docker

    Let's explore a process for running Ruby on Rails in Docker with Nginx to handle serving static assets.

  • November 5 2022

    Getting Familiar with RSpec in Rails

    I spent some time over the weekend getting familiar with RSpec. Gonna brain dump (with just a little bit of structure) the process and what I did and learned. To start I set up in a new rails project and kinda tweaked it into a place where I can be productive.

  • September 20 2022

    The difference between length, size, and count in Ruby on Rails

    I was asked recently if I could explain the difference between length, size, and count for ActiveRecord models in Ruby on Rails. Unfortunately I had no answer. But I wanted to really understand so I dug into the API docs.

  • March 11 2021

    Deploying a Simple Rails App with Ansible

    Ruby on Rails is quickly becoming my framework of choice for my personal websites and projects. It's a pleasure to work with and has been easy to learn. But no framework is without its challenges. One of those challenges is of course deploying the app to a server. There are a lot of options for hosting and deploying a Rails app. But, I like to run my own servers which means I have to also take care of deploying to those servers. I'd prefer to be deploying images to AWS ECS but I don't need that kind of infrastructure for my personal website. It's just a blog it can suffer seconds of downtime when I deploy updates. So my approach these days is to use Ansible to handle the deploy steps.

  • March 7 2021

    How to Run Rails App Server with Systemd and Ansible

    Create a systemd service to run your rails app server.

‹ Prev
Next ›