In case https://www.rubydoc.info/ is to slow or offline, you can also read a gem documentation offline. Start a server...

opensoul.org

I love ETags, but there’s something that annoys me: most implementations revolve around pulling a record out of a...

Are you adding a "Then show me the page" and re-run Cucumber whenever there is a failing scenario? Don...

If you're on Ubuntu: sudo apt-get install ruby-dev On other platforms: Look for a package containing ruby...

Call geordi clean from a project root to remove unused and unnecessary files inside it. This script is part of...

Update: This trick probably isn't very useful anymore in Ruby 2.x. The Ruby GC has improved a lot...

justinfrench.com

If you’re testing the behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec...

If you want to iterate over a Range, but only look at every n-th element, use the step method...

When your block takes an argument that should have an default, only in Ruby 1.9 you can say: block = lambda...

timeless.judofyr.net

This must be one of the coolest, yet quite unknown, technique in Ruby. For certain types of problems (e.g. when...

In regular expressions you can use the zero-width pattern \b to match the beginning or end of a word...

You can usually just use the eq matched to compare two numbers: expect(deal.total).to eq(120)

opensoul.org

How to create an infinitely nestable hash that always defaults to a new hash if a key does not map...

github.com

Ruby's net/http is setup to never verify SSL certificates by default. Most ruby libraries do the same. That means...

opensoul.org

Sometimes, you just need to shoot from the hip…or deploy your local changes without committing them. Put this snippet...

If you want to find out whether a Class object is directly inheriting from another class, use superclass: ActiveRecord::RecordNotFound.super...

RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2...

Use the htmlentities gem. Encoding works like this: require 'htmlentities' coder = HTMLEntities.new string = "<élan>" coder.encode(string) # => "&lt;élan&gt;"

You can get YAML.load to instantiate any Ruby object by embedding the desired class name into the YAML code. E.g...

Use the Launchy gem: Launchy.open('http://www.ruby-lang.org/')

apidock.com

To temporarily change the current working directory in Ruby, call Dir.chdir with a block. The previous working directory will be...

yehudakatz.com

The first thing you need to understand is that the purpose of refinements in Ruby 2.0 is to make monkey...

If you need to do calculations inside the database and can not use Ruby objects you may run into problems...

When a has_many association basically serves to store a list of associated strings (tags, categories, ...), it can be convenient...