Module: DbBrowser
- Defined in:
- lib/dbbrowser.rb,
lib/dbbrowser/server.rb,
lib/dbbrowser/version.rb
Defined Under Namespace
Classes: Server
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
-
.add_database_url ⇒ Object
helper for DATABASE_URL for ActiveRecord.
- .root ⇒ Object
Class Method Details
.add_database_url ⇒ Object
helper for DATABASE_URL for ActiveRecord
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dbbrowser.rb', line 25 def self.add_database_url str = ENV['DATABASE_URL'] if str.blank? puts "no ENV['DATABASE_URL'] found; skip adding DATABASE_URL config" return end #### # check/fix/todo: # for config key (use env for now) # use RACK_ENV or RAILS_ENV if present?? why? why not? # only if not already in config? possible? db = URI.parse( str ) ### use spec instead of config ??? if db.scheme == 'postgres' config = { adapter: 'postgresql', host: db.host, port: db.port, username: db.user, password: db.password, database: db.path[1..-1], encoding: 'utf8' } else # assume sqlite for now config = { adapter: db.scheme, # sqlite3 database: db.path[1..-1] # pluto.db (NB: cut off leading /, thus 1..-1) } end puts 'db settings:' pp config if ActiveRecord::Base.configurations.nil? puts "ActiveRecord configurations nil - set to empty hash" ActiveRecord::Base.configurations = {} # make it an empty hash end puts 'ar configurations (before):' pp ActiveRecord::Base.configurations ActiveRecord::Base.configurations['env'] = config puts 'ar configurations (after):' pp ActiveRecord::Base.configurations end |
.root ⇒ Object
7 8 9 |
# File 'lib/dbbrowser/version.rb', line 7 def self.root "#{File.( File.dirname(File.dirname(File.dirname(__FILE__))) )}" end |