Class: Database
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Database
- Defined in:
- app/models/database.rb
Constant Summary collapse
- @@conn =
nil
Class Method Summary collapse
- .connect_sql(adapter, host, port, username, password, database) ⇒ Object
- .connect_sqlite(path) ⇒ Object
Class Method Details
.connect_sql(adapter, host, port, username, password, database) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/database.rb', line 4 def self.connect_sql(adapter, host, port, username, password, database) SymmetricEncryption.load! # Load configuration items (MANDATORY, must be included) app_config = HashWithIndifferentAccess.new(YAML.load(File.read(File.('../../../config/dbms/dbms_config.yml', __FILE__)))) begin decryptedPassword = SymmetricEncryption.decrypt(password) establish_connection( :adapter => adapter, :host => host, :port => port.to_i, :username => username, :password => decryptedPassword, :database => database ) if (self.connection.nil?) return false else return true end rescue return false end end |
.connect_sqlite(path) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/database.rb', line 31 def self.connect_sqlite(path) begin establish_connection( :adapter => "sqlite3", :database => path ) if (self.connection.nil?) return false else return true end rescue return false end end |