Working with Frozen Hashes

I discovered a cool method today while working with a frozen hash containing a frozen array.

deep_dup

From the Rails API Documentation:

Returns a deep copy of hash.

 hash = { a: { b: 'b' } }
 dup  = hash.deep_dup
 dup[:a][:c] = 'c'

 hash[:a][:c] # => nil

Extract ActiveRecord Scope Method

Peer review today lead to a great refactoring opportunity. The pull request centered around allowing signed in site administrators to view unpublished blog posts.

Original

My goal here is to only have the published scope apply if the current_user is not an...

Optimize Rails Database Queries with Bullet and RSpec

Bullet is a gem that helps increase your application’s performance by reducing the number of queries it makes.

The README describes how to use the gem in Development but makes no special mention of how to use it in test with RSpec.

Searching through the gem...