Skip to content

Instantly share code, notes, and snippets.

@tuzz
Created April 14, 2012 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuzz/2387871 to your computer and use it in GitHub Desktop.
Save tuzz/2387871 to your computer and use it in GitHub Desktop.
A useful patch if you're subclassing AR 3.1.0-3.2.2
# Fixes dynamic find by method attempting to use the connection
# on ActiveRecord::Base in activerecord versions 3.1.0 to 3.2.2
# when it should be respecting the connection on its subclass
class QuoteTableNamePatch
def self.quote_table_name(name)
name
end
end
module ActiveRecord
module Associations
class AliasTracker
private
def connection
ActiveRecord::Base.connection
rescue ActiveRecord::ConnectionNotEstablished
QuoteTableNamePatch
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment