class method self.resolve_path

Ruby on Rails edge

Since edge

Signature

self.resolve_path(database, root: nil)

Returns a filesystem path to the database.

The configuration’s :database value may be a (slightly nonstandard) SQLite URI, so this method will resolve those URIs to a string path.

If Rails.root is available, this is guaranteed to be an absolute path.

See www.sqlite.org/uri.html

Parameters

database req
root key = nil
Source
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 82
        def resolve_path(database, root: nil)
          database = database.to_s
          root ||= defined?(Rails.root) ? Rails.root : nil

          path = if database.start_with?("file:/")
            URI.parse(database).path
          elsif database.start_with?("file:")
            URI.parse(database.split("?").first).opaque
          else
            database
          end

          if root.present?
            File.expand_path(path, root)
          else
            path
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb line 82 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::SQLite3Adapter

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close