This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation | |
# has_many and has_one through belongs_to are broken becuase the order of the primary key | |
# and foreign table key need to be reversed. this detects and fixes it. | |
def association_join_with_through_belongs_to_fix | |
join = association_join_without_through_belongs_to_fix | |
if [:has_many, :has_one].include?(reflection.macro) && reflection.options[:through] && source_reflection.macro == :belongs_to | |
connection = reflection.active_record.connection | |
parent_table_name = connection.quote_table_name(parent.aliased_table_name) | |
parent_key = connection.quote_column_name(parent.primary_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_spec(file) | |
unless File.exist?(file) | |
puts "#{file} does not exist" | |
return | |
end | |
puts "Running #{file}" | |
system "bundle exec rspec #{file}" | |
puts | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Response Headers* | |
Date Wed, 04 Jan 2012 03:14:33 GMT | |
Server Apache/2.2.3 (CentOS) | |
X-Powered-By Phusion Passenger (mod_rails/mod_rack) 3.0.2 | |
X-Runtime 0.976903 | |
Status 500 | |
Vary Accept-Encoding,User-Agent | |
Content-Encoding gzip | |
Content-Length 1267 | |
Content-Type text/html; charset=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git push heroku branch_name:master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb -r path_to_app.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'mocha' | |
# assumes MailingListUpdater is defined / exposed at the top level. this is not the case | |
# for the code in this gist. | |
class MailingListUpdaterTest < Test::Unit::TestCase | |
test "#update_mailing_list calls enqueue_for_mailing_list_update when a user is present" do | |
user = mock('User', :enqueue_for_mailing_list_update => true) | |
record = stub('Record') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
class VagrantSSHConfig < OpenStruct | |
def initialize | |
super parse_options(`vagrant ssh-config`) | |
end | |
private | |
def parse_options(option_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "http://rubygems.org" | |
gem 'thin' | |
gem 'cramp' | |
gem 'rack' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IOError: | |
closed stream | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:132:in `readline' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2770:in `read_chunked' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2750:in `read_body_0' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2710:in `read_body' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
, cors = require('connect-xcors')({ | |
headers: ['X-Requested-With', 'X-HTTP-Method-Override', 'Content-Type', 'Accept', 'Authorization'] | |
}) | |
var app = express() | |
// OPTIONS requests don't get handled because | |
// cors is hidden behind the routing middleware | |
// and '/' is only accessible via GET |
OlderNewer