Skip to content

Instantly share code, notes, and snippets.

View davekonopka's full-sized avatar
🔊

Dave Konopka davekonopka

🔊
View GitHub Profile
@davekonopka
davekonopka / Rakefile.rb
Last active June 22, 2016 04:42
WWW Rake file
namespace :site do
desc "Middleman build"
task :build do
puts "Building site..."
puts `bundle exec middleman build --verbose`
end
desc "Build, deploy, bust cache"
task :deploy => ["site:build", "s3:deploy", "fastly:bust_cache"]
@davekonopka
davekonopka / description.markdown
Created September 29, 2011 20:49 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

Philadelphia Emerging Technologies for the Enterprise conference, April 2010

Day 1

Keynote - Bad Code, Craftsmanship, Engineering, and Certification, Bob Martin

  • The only way to go fast is to go well.
  • Keep functions as short, single function as possible
  • Function is small enough when it can't get any smaller
  • Keep argument collection small