Skip to content

Instantly share code, notes, and snippets.

@dkubb
dkubb / .gitignore
Created December 5, 2011 18:26
Test Feedzirra w/VCR using an HTTP proxy
cassettes
@runemadsen
runemadsen / description.markdown
Created September 26, 2011 15:23
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.

@house9
house9 / Simple.Data.MongoDB.openMongo.cs
Created May 3, 2011 23:31
Simple.Data with MongoDB
using Simple.Data;
using Simple.Data.MongoDB;
// connect
dynamic db = Database.Opener.OpenMongo("mongodb://localhost:27017/myDB");
// insert
dynamic user = new ExpandoObject();
user.FirstName = "Joe";
user.LastName = "Smith";
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')