Skip to content

@metaskills /gist:4065702
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Example Of Other/Legacy DB Connection Management & Query Cache
# Assuming you champioin your other DB connection with a class.
module OtherDb
class Connection < ActiveRecord::Base
establish_connection :other_db
self.abstract_class = true
end
end
# Alway use the connection for other/legacy connections.
module OtherDb
class SomeModel < OtherDb::Connection
self.table_name = 'db_table_name'
self.primary_key = 'view_unique_identifier'
end
end
# Now let ActiveRecord cache those queries per request/response.
class ApplicationController < ActionController::Base
around_filter :cache_other_db_connection
protected
def cache_other_db_connection
OtherDb::Connection.connection.cache { yield }
end
end
@brentmc79

Not sure how gist pull requests work... https://gist.github.com/4449608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.