Module: ActiveRecord::ConnectionAdapters::ConstraintConnectionHook
- Included in:
- Base
- Defined in:
- lib/activerecord_constraint_handlers.rb
Overview
This module is included in ActiveRecord::Base. The example provided is for PostgreSQL. During the connect, the adapter specific connection routine is called. The name of that routine is the the adapter type with _connection
appened. e.g. postgresql_connection
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/activerecord_constraint_handlers.rb', line 261 def self.included(base) base.class_eval { class << self # An example for the postgresql adapter. Other adapters # need only add to this list with the proper name. def postgresql_connection_with_constraints(config) ActiveRecord::Base.logger.debug("IN: ConstraintConnectionHook::postgresql_connection_with_constraints #{self}") # Pass the call up the chain v = postgresql_connection_without_constraints(config) # After we return, add in Postgres' constraint handlers # into "self". Usually this will be ActiveRecord::Base # but I think if Model.establish_connection is called, # then self will be Model. include ConstraintHandlers::Postgresql # Return the original result. v end alias_method_chain :postgresql_connection, :constraints end } end |