Permalink
Browse files

Added relative path search for sqlite dbfiles in database.yml (if RAI…

…LS_ROOT is defined) #233 [bitsweat]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@34 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d6d875b commit bc80460115b534687a5311b03e8fd1ea06746419 @dhh dhh committed Dec 1, 2004
Showing with 5 additions and 2 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +3 −2 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -1,5 +1,7 @@
*CVS*
+* Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [bitsweat]
+
* Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable
* Added ADO-based SQLServerAdapter (only works on Windows) [Joey Gibson]
@@ -12,7 +12,8 @@ def self.sqlite_connection(config) # :nodoc:
unless config.has_key?(:dbfile)
raise ArgumentError, "No database file specified. Missing argument: dbfile"
end
-
+
+ config[:dbfile] = File.join(RAILS_ROOT, config[:dbfile]) if config[:dbfile] =~ /^\w/ && Object.const_defined?(:RAILS_ROOT)
db = SQLite::Database.new(config[:dbfile], 0)
db.show_datatypes = "ON" if !defined? SQLite::Version
@@ -102,4 +103,4 @@ def table_structure(table_name)
end
end
end
-end
+end

0 comments on commit bc80460

Please sign in to comment.