forked from jeremyevans/roda-sequel-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.rb
More file actions
25 lines (20 loc) · 763 Bytes
/
models.rb
File metadata and controls
25 lines (20 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true
require_relative 'db'
require 'sequel/model'
if ENV['RACK_ENV'] == 'development'
Sequel::Model.cache_associations = false
end
Sequel::Model.plugin :auto_validations
Sequel::Model.plugin :require_valid_schema
Sequel::Model.plugin :subclasses unless ENV['RACK_ENV'] == 'development'
unless defined?(Unreloader)
require 'rack/unreloader'
Unreloader = Rack::Unreloader.new(reload: false, autoload: !ENV['NO_AUTOLOAD'])
end
Unreloader.autoload('models'){|f| Sequel::Model.send(:camelize, File.basename(f).sub(/\.rb\z/, ''))}
if ENV['RACK_ENV'] == 'development' || ENV['RACK_ENV'] == 'test'
require 'logger'
LOGGER = Logger.new($stdout)
LOGGER.level = Logger::FATAL if ENV['RACK_ENV'] == 'test'
DB.loggers << LOGGER
end