Skip to content

Instantly share code, notes, and snippets.

View clowder's full-sized avatar

Chris Lowder clowder

  • London
View GitHub Profile
layout title description tags
default
SQL Style Guide
A guide to writing clean, clear, and consistent SQL.
data
process

Purpose

@clowder
clowder / active_record_helper.rb
Created July 4, 2012 21:41 — forked from mudge/active_record_helper.rb
A bare-bones spec helper for testing Active Record classes without the rest of Rails.
# Note that this *will not load your Rails configuration* which means things like
# mass assignment protection by default, etc. will not be set.
require "active_record"
ActiveRecord::Base.configurations = YAML.load_file(File.expand_path("../../config/database.yml", __FILE__))
ActiveRecord::Base.establish_connection("test")
# Stick your ActiveRecord junk (i.e. extensions) here
require "database_cleaner"
@clowder
clowder / hack.sh
Created May 20, 2012 17:26 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@clowder
clowder / gist:1451644
Created December 9, 2011 14:04 — forked from mudge/gist:263139
Polymorphic has_many :through in Rails 2.3
# A polymorphic has_many :through relationship in Rails 2.3
# based on Josh Susser's "The other side of polymorphic :through associations"
# http://blog.hasmanythrough.com/2006/4/3/polymorphic-through
class Authorship < ActiveRecord::Base
belongs_to :author
belongs_to :publication, :polymorphic => true
end
class Author < ActiveRecord::Base
has_many :authorships
# implementation at http://gist.github.com/3350
require 'spec_helper'
describe HoptoadErrors do
describe '.find :all' do
before(:each) do
@errors = HoptoadErrors.find :all
end