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…
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…
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…
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…
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…
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…
Cucumber in Rails
Let's see how to implement Cucumber in Rails. Cucumber is a tool that helps you test your web application. It does this by running automated tests written in a language called Gherkin.
Gherkin is a plain-text language with a few simple rules. It's designed to be easy to learn and easy to read.
How Cucumber…
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…
Cron Jobs in Rails
In this article will show you how to implement cron jobs in Rails. A cron job is a type of job or task executed at a particular time or interval.
This can be very useful if you want to automate certain tasks like sending emails, backing up databases, etc.
Rails come with a gem…
PaperTrail in Rails
PaperTrail is a Ruby Gem that allows you to keep track of changes made to your models and store them as versions.
You can revert back to older versions if you need to, which can be really handy.
Installing PaperTrail is pretty simple, you just need to add it to your Gemfile.
gem 'paper_trail', '~> 10.0'
Using…