Created
April 30, 2012 06:39
-
-
Save shuujii/2556038 to your computer and use it in GitHub Desktop.
ActiveRecord SQLite3 adapter with foreign 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
module ActiveRecord | |
class Base | |
class << self | |
def sqlite3_connection_with_foreign_key(config) | |
sqlite3_connection_without_foreign_key(config).tap do |db| | |
db.execute("PRAGMA foreign_keys = ON") if config[:foreign_key] | |
end | |
end | |
alias_method_chain :sqlite3_connection, :foreign_key | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment