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.
6 7 8 |
# File 'lib/conjoin/active_record.rb', line 6 def app @app end |
Class Method Details
.setup(app) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/conjoin/active_record.rb', line 9 def self.setup app require 'mini_record' self.app = app ActiveRecord::Base.send :include, Form if not Conjoin.env.mounted? require 'enumerize' require 'protector' Protector::Adapters::ActiveRecord.activate! start_active_record ActiveRecord::Base.default_timezone = Time.zone end end |
.start_active_record ⇒ Object
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 |
# File 'lib/conjoin/active_record.rb', line 25 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.establish_connection( 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 ) end |