Skip to content

Instantly share code, notes, and snippets.

@mikhailov
Created July 2, 2012 08:32
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 mikhailov/3031943 to your computer and use it in GitHub Desktop.
Save mikhailov/3031943 to your computer and use it in GitHub Desktop.
Rails 3.2 monkey-patch to enable Mysql strict mode by default
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
private
alias_method :configure_connection_without_strict_mode, :configure_connection
def configure_connection
configure_connection_without_strict_mode
strict_mode = "SQL_MODE='STRICT_ALL_TABLES'"
execute("SET #{strict_mode}", :skip_logging)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment