Skip to content

Instantly share code, notes, and snippets.

@emarthinsen
emarthinsen / subscription_factory.rb
Created December 6, 2012 04:01
Traits in Associations
(rdb:1) p FactoryGirl.build(:user, :pro, :active)
ArgumentError Exception: Factory not registered: [:subscription, :pro]
(rdb:1) p FactoryGirl.build(:subscription, :pro)
#<Subscription id: nil, user_id: nil, plan: "pro", renew_on: "2012-12-13", charge_on: "2012-12-13", failures: 0, created_at: nil, updated_at: nil>
@emarthinsen
emarthinsen / scrape.rb
Created November 1, 2012 20:00
URL Scraper
def scrape_url(url)
url_found = false
twitter_name = nil
begin
agent = Mechanize.new do |a|
a.follow_meta_refresh = true
end
agent.get(normalize_url(url)) do |page