Module: Conjoin::ActiveRecord
- Includes:
- ActiveRecord
- Defined in:
- lib/conjoin/active_record.rb
Defined Under Namespace
Modules: Form
Class Attribute Summary collapse
-
.app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
Class Attribute Details
.app ⇒ Object
Returns the value of attribute app.
12 13 14 |
# File 'lib/conjoin/active_record.rb', line 12 def app @app end |
Class Method Details
.setup(app) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/conjoin/active_record.rb', line 15 def self.setup app self.app = app ActiveRecord::Base.send :include, Form # if not Conjoin.env.mounted? unless ActiveRecord::Base.connected? start_active_record ActiveRecord::Base.default_timezone = Time.zone end end |
.start_active_record ⇒ Object
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 |
# File 'lib/conjoin/active_record.rb', line 28 def self.start_active_record # if not Conjoin.env.test? # return if ActiveRecord::Base.connected? # else if ActiveRecord::Base.connected? ActiveRecord::Base.connection.disconnect! end # end # ActiveRecord::Base.logger = Logger.new(STDERR) unless @app.test? db = URI.parse ENV['DATABASE_URL'] ActiveRecord::Base.configurations = { 'default' => { adapter: db.scheme == 'postgres' ? 'postgresql' : db.scheme, encoding: 'utf8', reconnect: true, database: db.path[1..-1], host: db.host, port: db.port, pool: ENV['DATABASE_POOL'] || 5, username: db.user, password: db.password, wait_timeout: 2147483 } } ActiveRecord::Base.establish_connection('default') end |