Returns name of the database. Sqlite3’s handling of a leading slash is in
transition as of Rails 4.1.
# File activerecord/lib/active_record/connection_adapters/connection_specification.rb, line 96
def database_from_path
if @authority && @adapter == 'sqlite3'
# 'sqlite3:///foo' is relative, for backwards compatibility.
database_name = uri.path.sub(%{^/}, "")
msg = "Paths in SQLite3 database URLs of the form `sqlite3:///path` will be treated as absolute in Rails 4.2. " "Please switch to `sqlite3:#{database_name}`."
ActiveSupport::Deprecation.warn(msg)
database_name
elsif @adapter == 'sqlite3'
# 'sqlite3:/foo' is absolute, because that makes sense. The
# corresponding relative version, 'sqlite3:foo', is handled
# elsewhere, as an "opaque".
uri.path
else
# Only SQLite uses a filename as the "database" name; for
# anything else, a leading slash would be silly.
uri.path.sub(%{^/}, "")
end
end