Ruby General
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
bin/console
Done.
Or,
bundle console
Or,
irb -I lib
require "name_of_gem"
For example:
$ i...
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:
config/code_schools.yml
You'll grab the path to the file, and load its contents:
config = Rails.root + 'config/code_schools.yml'
...
1 vote - harrylevine
06/20/16 Public, Troubleshooting, Ruby General
This is commonly caused by having return
called within a block.
Here is an example. This example triggered an Airbrake error of type LocalJumpError:
task :decrement_taken_pto_...
1 vote - harrylevine
06/16/16 Public, Ruby General
I had this method to start with:
NON_DEDUCTIBLE_REASONS = ['Jury Duty', 'Bereavement']
def self.attendance_status_ids
ids = []
NON_DEDUCTIBLE_REASONS.each do |reason|
ids << AttendanceStatus.find_by_name(reason.to_s.t...
1 vote - harrylevine