Skip to content

Instantly share code, notes, and snippets.

@wreimers
Created December 14, 2011 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wreimers/1478997 to your computer and use it in GitHub Desktop.
Save wreimers/1478997 to your computer and use it in GitHub Desktop.
A Rails 3.1 initializer to monkeypatch the mysql2 AR adapter.
ActiveRecord::Base.connection.execute("SELECT 1")
module ActiveRecord
module ConnectionAdapters
class Mysql2Adapter
def create_table(table_name, options = {})
super(table_name, options.reverse_merge(:options => "ENGINE=ndbcluster"))
end
end
end
end
@wreimers
Copy link
Author

Why the fake db call you ask? So Rails 3.1 initializes the adapter properly before I patch it. If you simply 'require' the module, it bails out later as it is not initialized properly.

@jude90
Copy link

jude90 commented Jul 2, 2015

where shall I put the monkey patch script , make rails load it properly ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment