Skip to content

Instantly share code, notes, and snippets.


Tyler Rick TylerRick

  • USA
View GitHub Profile
TylerRick / content_for_inside_cache.rb
Last active Jun 11, 2020 — forked from stackng/rails content_for caching
Add ability to use content_for within a fragment cache block (Rails 5.2)
View content_for_inside_cache.rb
# config/initializers/content_for_inside_cache.rb
module AbstractController
class Base
attr_internal :cached_content_for
module Caching
# actionpack/lib/action_controller/caching/fragments.rb
module Fragments
TylerRick / detailed_hash_diff.rb
Last active May 26, 2020 — forked from fabriciofreitag/detailed_hash_diff.rb
Custom RSPec matcher for detailed hash compasion and diff
View detailed_hash_diff.rb
require 'facets/hash/recurse'
# Usage:
# expect(actual).to match_hash(expected)
RSpec::Matchers.define :match_hash do |expected|
match do |actual|
# Sort hashes before comparing so that the diff only shows actual changes between keys and
# values.
actual = actual.recurse {|h| h.sort_by {|k,v| k.to_s }.to_h }
TylerRick / .gitignore
Created Jan 19, 2018 — forked from ZJONSSON/force_labels.js
Automatic floating labels using d3 force-layout
View .gitignore
TylerRick / main.rb
Created Jan 16, 2018 — forked from coorasse/main.rb
CanCanCan Issue
View main.rb
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
gemfile(true) do
source ''
gem 'rails', '5.1.4'
View spree_export_import.rake
namespace :spree do
desc "Export Products to CSV File"
task :export_products => :environment do
require 'csv'
products = Product.where(:deleted_at => nil).all
puts "Exporting to #{RAILS_ROOT}/products.csv""#{RAILS_ROOT}/products.csv", "w") do |csv|
csv << [