Skip to content

Instantly share code, notes, and snippets.

@bpardee
bpardee / gist:9059ac69b2dd1e46e0232d5fd542fb94
Created September 21, 2016 15:49
Intermittent count error in Rails 4.2.7.1
undefined method `visit_Arel_Nodes_Casted' for #<Arel::Visitors::DepthFirst:0x7dc2a61b>
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/visitor.rb:29visit
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/depth_first.rb:12visit
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/depth_first.rb:63binary
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/visitor.rb:29visit
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/depth_first.rb:12visit
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/depth_first.rb:17unary
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/visitor.rb:29visit
vendor/bundle/jruby/2.3.0/gems/arel-6.0.3/lib/arel/visitors/depth_first.rb:12visit
@bpardee
bpardee / assert_csv.rb
Created September 22, 2015 11:47
assert csv file
module AssertCSV
def assert_csv(expected_csv_path, options={}, &block)
ignore = options[:ignore] || []
actual_csv_string = CSV.generate { |actual_csv| yield actual_csv }
actual_rows = CSV.parse(actual_csv_string)
expected_rows = CSV.read(expected_csv_path)
if ENV['STORE_ACTUAL_CSV'] && actual_rows != expected_rows
CSV.open("#{expected_csv_path}.actual", "wb") {|csv| actual_rows.each {|row| csv << row}}
end
assert_equal expected_rows.size, actual_rows.size
@bpardee
bpardee / active_record_test.rb
Last active August 29, 2015 14:13
ActiveRecord threadsafe test
require 'active_record'
puts "Active Record #{ActiveRecord::VERSION::STRING}"
# TODO: How to get past sqlite3_connection undefined error?
# ActiveRecord::Base.establish_connection(
# :adapter => 'jdbcsqlite3',
# :database => ':memory:'
# )
ActiveRecord::Base.establish_connection(
@bpardee
bpardee / test_it.rb
Created October 13, 2013 12:52
ActiveRecord time parse test
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails', branch: '4-0-stable'
#gem 'rails', github: 'rails/rails'
#gem 'rails'
gem 'sqlite3'
#gem 'pg'
GEMFILE
Script started on Thu Aug 22 06:46:34 2013
~/Documents/myapp> rm -rf tmp/cache
~/Documents/myapp> r s
=> Booting Puma
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.5.1 starting...
* Min threads: 0, max threads: 16
* Environment: development
@bpardee
bpardee / another_strange_error.log
Created August 16, 2011 18:55
ActiveRecord says connection timeout when it ain't so
NameError: uninitialized constant Relation
load_missing_constant at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:509
const_missing at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183
each at org/jruby/RubyArray.java:1603
const_missing at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181
relation at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activerecord-3.0.9/lib/active_record/base.rb:906
scoped at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activerecord-3.0.9/lib/active_record/named_scope.rb:32
first at /Users/bpardee/.rvm/gems/jruby-1.6.3@claritybase/gems/activerecord-3.0.9/lib/active_record/base.rb:444
__file__ at ar_test.rb:26
call at org/jruby/RubyProc.java:268