I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...

makandra dev
sitepoint.com

Scope is all about where something is visible. It’s all about what (variables, constants, methods) is available to you...

You can use local copies of gems in your Gemfile like this: gem 'spreewald', path: '~/gems/spreewald' As soon as you...

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

makandra dev

If you use the Better Errors gem, you will sometimes notice that it can be very slow. This is because...

Nowadays it is fairly easy to intercept and modify mails globally before they are sent. All you have to do...

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

You can use gem list to list all gems available from a remote gem server: gem list -r --clear-sources...

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

Middleman is a static page generator that brings many of the goodies that Rails developers are used to.

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

github.com

The parallel-gem is quite easy to use and can speed up rendering time if you want to render the...

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

Note: The behaviour of Spreewald's within step is as described below for version < 1.9.0; For Spreewald >= 1.9.0 it is...

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