Skip to content

Commit

Permalink
fallback to default db in multisite env.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfl62 committed Feb 2, 2009
1 parent 5e85877 commit 1b329d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/application.rb
Expand Up @@ -60,10 +60,16 @@ def current_location
end
end

def database_string
FileTest.exists?(Rails.root + '/db/' + current_location + '.sqlite3') ?
Rails.root + '/db/' + current_location + '.sqlite3' :
Rails.root + '/db/development.sqlite3'
end

def current_database
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => Rails.root + '/db/' + current_location + '.sqlite3'
:database => database_string
)
end

Expand Down

0 comments on commit 1b329d3

Please sign in to comment.