Ruby Templating Engines: ERB, HAML & Slim

ERB is a templating engine. A templating engine allows you to mix HTML & Ruby so you can generate web pages using data from your database. ERB is Rails default engine for rendering views. Note: Rails uses an implementation called erubi instead of the ERB class from the Ruby standard library. As you’ll learn later … Read more

Ruby Interview Coding Challenges & How to Solve Them

Doing coding challenges is an excellent way to improve your Ruby & problem-solving skills. And to prepare for coding interviews! Why? Because during a challenge you put all your focus on solving 1 specific problem. You don’t have to worry about anything else. This kind of practice will expand your thinking skills, allow you to … Read more

How to Check If a Variable is Defined in Ruby

Ruby has this defined? keyword that helps you check if a variable is defined or not. If the variable exists you’ll get its type: apple = 1 defined?(apple) # “local-variable” If it doesn’t you’ll get nil: defined?(bacon) # nil This is like Javascript’s typeof operator. If you want to know the class of an object … Read more