class and instance eval in Ruby

Ruby’s class_eval and instance_eval though the names are similar but have rather counterintuitive behaviour.

A simple explanation to each is:

ClassName.class_eval : It’s used to define an instance method on a class object which applies on all the instances of the class.

ClassName.instance_eval : It’s used to define a class…

STI Rails

What is STI in Rails ?

Single Table Inheritance in Rails is a technique used to categorize a base model into multiple sub-classes OR groups without needing to create new tables in the database.

A normal use case would be to have multiple models with almost the same attributes, hence…

The problem that we will address in this article:

Send an email over HTTP calls instead of SMTP delivery method in rails application but the existing code such as UserMailer.send_reset_password.deliver_now should still work.


We can achieve this by following 3 steps as below:

  1. Write a class that responds to the actual deliver! method of ActionMailer.
  2. Register this new mailer class in ActionMailer::Base.
  3. Update the config.delivery_methodin thedevelopment.rb and production.rb config files.
steps for adding custom delivery method

And you are done !!! Now you will be able to send emails using your custom-defined delivery method.

Also, you don’t need to change your existing code as the above setup adds a provision to keep the existing ActionMailer behaviour along with the custom logic to execute.

Any suggestions on above are much appreciated. Share it if you like it.


Before moving onto Rails & Docker setup let’s quickly understand what exact problem does docker really solve.

So we already have VMs which pretty much fulfils the purpose of setting up a separate machine with its own config. Hence docker didn’t solve the isolation problem, as that was solved by…

Recently in one of my React projects, I stumbled upon a weird error where the variable expected to be printed was actually printed as undefined. Ehhh… this doesn’t sound new right !!!

Let me explain you with an example:

Basic use of this keyword.

This works perfectly fine and gives…

Huzefa S Biyawarwala

Ruby On Rails | MongoDB | ReactJS | AWS | Freelance Consultant

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store