makandra dev

In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This...

I often see the use of || to set a default value for a variable that might be nil, null or...

ActiveRecord::RecordNotFound errors provide quite meaningful error messages that can provide some insight on application details. Consider the following:

This card will show you a cool way to define a class using Struct.new. A common usecase for Structs are...

Rails supports time zones, but there are several pitfalls. Most importantly because Time.now and Time.current are completely different things and...

makandra dev
stdgems.org

Ruby's standard library is in the process of being gemified. It will soon - Ruby 2.5 - consist of RubyGems, which...

Dump this method into your Ruby console to quickly print data in columns. This is helpful for e.g. comparing attributes...

In case you want to require a gem, that is not in the Gemfile of you bundle and therefore not...

makandra dev

This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the...

Sass lets you easily specify multiple selectors at once like this: .some-block &.has-hover, &:hover outline: 1px solid red...

github.com

Barby is a great Ruby gem to generate barcodes of all different sorts. It includes support for QR codes via...

makandra dev
activestate.com

Looks like ActiveState is trying to market a new Ruby distribution for Enterprises: ActiveRuby Enterprise Edition is designed for businesses...

There are various ways to run external commands from within Ruby, but the most powerful ones are Open3.capture3 and Open3.popen3...

stackoverflow.com

A collection of code snippets which return a boolean value for a regex comparison. regexp.match?(string) # Recommended for Ruby >= 2.4...

evilmartians.com

Adding a gem means you take over the liability towards the external code. Checklist Based on "To gem, or not...

makandra dev

We have projects that have been developed using many different versions of Ruby. Since we do not want to...

deadlock 0x7f8a4160a360: sleep:- (main) - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:43 deadlock 0x7f8a38c03b08: sleep:- - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:56 *** longjmp causes uninitialized stack frame ***: /home/me/.rbenv/versions/1.8.7-p375/bin/ruby terminated

github.com

There are some inconvenient Gem dependencies. Resolve them by adding/modifying these lines in your Gemfile: gem 'guard-livereload', '>= 2.5.2', require...

lists.ruby-lang.org

TruffleRuby is an experimental Ruby implementation that tries to achieve ~10x performance over MRI. This has been on our radar...

Sometimes huge refactorings or refactoring of core concepts of your application are necessary for being able to meet new requirements...

makandra dev

You may know the double asterisk operator from Ruby snippets like Dir['spec/**/*_spec.rb'] where it expands to an arbitrary...

Ruby's regular expressions can be represented differently. When serializing them, you probably want to use inspect instead of to...

So you're getting an error like this: undefined method `activate_bin_path' for Gem:Module (NoMethodError)