Skip to content

Instantly share code, notes, and snippets.

View danmcclain's full-sized avatar

Dan McClain danmcclain

View GitHub Profile
require 'test_helper'
require 'rails/generators/test_case'
require 'active_support/core_ext/object/to_json'
require 'generators/party_foul/install_generator'
class InstallGeneratorTest < Rails::Generators::TestCase
tests PartyFoul::InstallGenerator
destination File.expand_path('../tmp', File.dirname(__FILE__))
setup :prepare_destination
--type-add
ruby=.haml
--type-add
css=.scss,.sass
--type-set
coffee=.hamlc,.coffee
--ignore-dir=log/
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-rails-source-maps (1.0.0)
coffee-script-source (>= 1.6.1)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.1)
--type-add
ruby=.haml
--type-add
css=.scss,.sass
--type-set
coffee=.hamlc,.coffee
--ignore-dir=log/
--color
irb(main):001:0> Something.where.any(stuff: 1)
ArgumentError: tried to create Proc object without a block
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/bundler/gems/squeel-c232bf9ea924/lib/squeel/adapters/active_record/relation_extensions.rb:222:in `new'
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/bundler/gems/squeel-c232bf9ea924/lib/squeel/adapters/active_record/relation_extensions.rb:222:in `where'
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:9:in `where'
from (irb):1
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /Users/dan/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>
@danmcclain
danmcclain / gist:6080928
Created July 25, 2013 15:32
MiniTest-spec-rails error
E/Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:153:in `include': wrong argument type Class (expected Module) (TypeError)
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:153:in `block in add_template_helper'
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:153:in `module_eval'
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:153:in `add_template_helper'
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:96:in `block in helper'
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/helpers.rb:95:in `each'
from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gem
@danmcclain
danmcclain / gist:6251047
Created August 16, 2013 15:48
Recreating has_many-ish functionality using PostgreSQL array columns
class Parent < ActiveRecord::Base
#parent has an array column that stores the integers of child records
def child_records
self.class.where(id: child_record_ids)
end
def child_records=(children)
self.child_record_ids = children.map(&:id)
end
@danmcclain
danmcclain / gist:6377132
Created August 29, 2013 11:56
All access on a AWS bucket
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:*"],
"Resource": ["arn:aws:s3:::<bucketname>/*"]
}
]
}
@danmcclain
danmcclain / Person.rb
Last active December 30, 2015 08:39
ActiveRecord mapping: In query.rb, which query generates the desired SQL? Which query *would you expect* to create the desired SQL?
class Person < ActiveRecord::Base
has_many :post_tags, class_name: 'Tag'
end
# Migration
create_table :person do |t|
t.timestamps
end
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end