Search code examples
rubydatabase-cleaner

NoMethodError: undefined method `url_whitelist=' for DatabaseCleaner:Module


In the safeguard document section, it says we could specify whitelist url:

In Ruby, a URL whitelist can be specified. When specified, DatabaseCleaner will only allow DATABASE_URL to be equal to one of the values specified in the url whitelist like so:

But I am getting a NoMethodError:

require "database_cleaner"
DatabaseCleaner.url_whitelist = %w(mysql2://root@mysql)
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)

This url_whitelist is defined here, introduced in this pull request.

Using DatabaseCleaner 1.7.0.


Solution

  • Current latest version 1.7.0 does not include this method 🤦🏻‍♀️

    Use master branch instead for now as of 2018 August 9th.

    You can check if a newer version has been released at here.