How do I get ruby to print a full backtrace instead of a truncated one?

When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me: tmp.rb:7:in `t’: undefined method `bar’ for nil:NilClass (NoMethodError) from tmp.rb:10:in `s’ from tmp.rb:13:in `r’ from tmp.rb:16:in `q’ from tmp.rb:19:in `p’ from tmp.rb:22:in `o’ from tmp.rb:25:in … Read more

Understanding the Gemfile.lock file

After running the bundle install command, ‘Gemfile.lock‘ is created in the working directory. What do the directives inside that file mean? For example, let’s take the following file: PATH remote: . specs: gem_one (0.0.1) GEM remote: http://example.org/ specs: gem_two (0.0.2) gem_three (0.0.3) gem_four (0.0.4) PLATFORMS platform DEPENDENCIES gem_two gem_one! What do ‘PATH‘, ‘GEM‘, ‘PLATFORMS‘ and … Read more

Ruby class instance variable vs. class variable

I read https://stackoverflow.com/questions/826734/when-do-ruby-instance-variables-get-set but I’m of two minds when to use class instance variables. Class variables are shared by all objects of a class, Instance variables belong to one object. There’s not much room left to use class instance variables if we have class variables. Could someone explain the difference between these two and when … Read more

Can I invoke an instance method on a Ruby module without including it?

Background: I have a module which declares a number of instance methods module UsefulThings def get_file; … def delete_file; … def format_text(x); … end And I want to call some of these methods from within a class. How you normally do this in ruby is like this: class UsefulWorker include UsefulThings def do_work format_text(“abc”) … … Read more