How To Delegate Methods in Ruby & Ruby on Rails

This article is about method delegation in Ruby. You’re going to learn how to use the delegate method, the Forwardable module & the SimpleDelegator class. Why do we need delegation? In Object-Oriented Programming, there are two ways for classes to work together. They are: Inheritance Composition With inheritance, you create class hierarchies, where a parent … Read more

Ruby Gems, Gemfile & Bundler (The Ultimate Guide)

What is a Ruby gem? A gem is a package that you can download & install. When you require an installed gem you’re adding extra functionality to your Ruby program. Gems allow you to: Add a login feature to your Rails app Easily work with external services (like APIs) Build a web application That’s just … Read more

How to Use The Ruby Super Keyword

What does the super keyword do in Ruby? It calls a method on the parent class with the same name as the method that calls super. For example: If you call a method named i_like_chocolate, and then you call super within that method, Ruby will try to find another method with that same name on … Read more

Rack Explained For Ruby Developers

What is happening behind the scenes of every Rails, Sinatra, and other Ruby web frameworks? The answer is Rack, the key component that makes this possible. But what is Rack exactly? Rack is a layer between the framework (Rails) & the application server (Puma). It’s the glue that allows them to communicate. Why Do We … Read more