Skip to content Skip to footer

All Posts

How to use the Decorator Pattern in Ruby
Decorator Pattern In Ruby There are many different ways to implement decorators in Ruby. In this article, we'll look at a couple of approaches to using the decorator pattern in Ruby. Decorators are a design pattern that allows you to add behavior to an existing class without subclassing it. Because they use composition instead of inheritance, they are…
Implement Ruby Service Pattern
Ruby Service Ruby Service is a great way to organize your code and make it more maintainable. Services are often used for: Sending emails Modifying data Sending notifications Services Should Be Atomic Services should be designed so that they only do one thing and do it well. This means that a service should not be too…
Implement ActiveStorage in Rails
ActiveStorage ActiveStorage is a new way to handle file attachments for Rails applications. In the past, you would have used Paperclip or CarrierWave to handle file attachments. But ActiveStorage is the new standard and is much simpler to use. This article will teach you how to use ActiveStorage to attach files to your Rails models. ActiveStorage Basics ActiveStorage is designed…
How to Create Engines in Rails
Engines in Rails This article will teach you how to use the engines in Rails. Rails engine is a Rails plugin that provides additional functionality to an existing Rails application. For example, a Spree Commerce engine allows you to turn your Rails application into an e-commerce website. What is an Engine in Rails? A Rails engine is a Ruby…
Integrating Elasticsearch in Rails
Elasticsearch in Rails In this article, we'll see how to use Elasticsearch in Rails application. Elasticsearch is a distributed, RESTful search and analytics engine. You can use it to search and analyze large amounts of data very quickly. We will use the elasticsearch-rails and elasticsearch-model gems to integrate elasticsearch into our rails application. These gems are provided by the…
How to Use Builder Pattern in Ruby
Builder Pattern in Ruby Let's see how to implement the Builder Pattern in Ruby. The builder pattern is an object creation software design pattern. Its interpretation in Ruby is quite elegant. For example, let's say you have a User class and want to give your users the ability to change their names and email addresses. You could…
How to Implement AASM in Ruby
AASM The AASM gem is a very popular way to implement state machines in Ruby. With AASM you can: Define the state machine without modifying your model. Easily create new states with actions & conditions. Persist the states in the database. If you want to get started quickly with AASM, this article is for…