Ruby General

Not learning Ruby is a bit like knowing how to fly a plane…on the ground.
Without Ruby, there is no Rails. Ruby is the backbone. It would be wise to have a reasonably solid Ruby foundation before adding on Rails. After that you will hit a certain point where you’ll realize that, in order to enact a desired feature for your web app, you’ll need to apply more advanced Ruby tactics. This will also come into play when trying to understand other developer’s code. As you move further down your Ruby learning path, your eyes will open wider to how much you can do with Ruby, and all the elegant and clever ways people apply Ruby to accomplish a given task. You will want to remember these. This stack is dedicated to capturing these moments of Ruby enlightenment.

Difference between include vs extend

03/05/18  Public, Ruby General

Great article by that explains the difference between using include vs extend andself, when using modules:

1 vote - harrylevine

Require and load a gem in IRB for testing purposes while developing the gem

01/20/18  Public, Ruby General, Gems

  • cd into the root of the gem
  • run bin/console



  • cd into the root of the gem
  • run bundle console


  • cd into the root of the gem
  • run irb -I lib
  • run require "name_of_gem"

For example:

$ i...

1 vote - harrylevine

Benchmarking in the Rails Console

01/01/18  Public, Ruby General, Rails Errors

timing = Benchmark.measure { Post.all }

The various attributes of the object returned (Benchmark::Tms) are provided here.

Here is a sample applicati...

1 vote - harrylevine

Set up a Ruby project with RSpec

11/12/17  Public, Ruby General, Testing / TDD

First make sure you have rspec and byebug installed:

➜  byebug -v
  Running byebug 9.1.0
➜  rspec -v
RSpec 3.6
  - rspec-core 3.6.0
  - rspec-expectations 3.6.0
  - rspec-mocks 3.6.0
  - rspec-rails 3.6.1
  - rspec-support ...

1 vote - harrylevine

Iterate over a .yml file's contents

07/01/17  Public, Rails General, Ruby General

Let's assume that the .yml file (i.e. code_school.yml) is located in this directory:


You'll grab the path to the file, and load its contents:

config = Rails.root + 'config/code_schools.yml'

1 vote - harrylevine