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.

Explanation of the Singleton Pattern in ruby

06/18/18  Public, Ruby General

https://ieftimov.com/singleton-pattern

1 vote - harrylevine

Set up a Ruby project with RSpec

06/11/18  Public, Testing / TDD, Ruby General

1. 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-supp...

1 vote - harrylevine

Difference between include vs extend

03/05/18  Public, Ruby General

Great article by https://twitter.com/feministy that explains the difference between using include vs extend andself, when using modules:

http://lizabinante.com/blog/modules-and-self-in-ruby/

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

Done.

Or,

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

Or,

  • 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, Rails Errors, Ruby General

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