Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix autoload deprecation #808

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem "graphql", "~> 2.0"
gem 'graphiql-rails'
gem "ember-cli-rails", "0.10.0"
if ENV["EMBER_ENABLED"]
gem "ember-cli-rails", "0.10.0"
end
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
gem "exception_notification", "~> 4.5"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ember_cli/ember_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def redirect_if_unsupported
end
end
end
end
end
1 change: 1 addition & 0 deletions ci_env.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ DATABASE_PASSWORD=password
DATABASE_NAME=r_solutions_test
DATABASE_PORT=5432
APP_HOST=restarone.com
EMBER_ENABLED=true
7 changes: 5 additions & 2 deletions config/initializers/active_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
class ActiveJob::Base
include Apartment::ActiveJob

Rails.application.reloader.to_prepare do
class ActiveJob::Base
include Apartment::ActiveJob
end
end
18 changes: 10 additions & 8 deletions config/initializers/active_storge.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
if Rails.env == 'production' || Rails.env == 'test'
require 'active_storage/attachment'
Rails.application.reloader.to_prepare do
if Rails.env == 'production' || Rails.env == 'test'
require 'active_storage/attachment'

class ActiveStorage::Attachment
before_save :ensure_storage_limit_not_exceeded
class ActiveStorage::Attachment
before_save :ensure_storage_limit_not_exceeded

def ensure_storage_limit_not_exceeded
unless Subdomain.current.has_enough_storage?
errors.add(:subdomain, 'out of storage')
throw(:abort)
def ensure_storage_limit_not_exceeded
unless Subdomain.current.has_enough_storage?
errors.add(:subdomain, 'out of storage')
throw(:abort)
end
end
end
end
Expand Down
20 changes: 11 additions & 9 deletions config/initializers/ahoy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class Ahoy::Store < Ahoy::DatabaseStore
end
Rails.application.reloader.to_prepare do
class Ahoy::Store < Ahoy::DatabaseStore
end

# set to true for JavaScript tracking
Ahoy.api = false
# set to true for JavaScript tracking
Ahoy.api = false

# set to true for geocoding
# we recommend configuring local geocoding first
# see https://github.com/ankane/ahoy#geocoding
Ahoy.geocode = true
Ahoy.job_queue = :default
# set to true for geocoding
# we recommend configuring local geocoding first
# see https://github.com/ankane/ahoy#geocoding
Ahoy.geocode = true
Ahoy.job_queue = :default
end
187 changes: 96 additions & 91 deletions config/initializers/apartment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,116 +13,121 @@
#
# Apartment Configuration
#
Apartment.configure do |config|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
#
config.excluded_models = %w{ Subdomain SubdomainRequest}
Rails.application.reloader.to_prepare do
Apartment.configure do |config|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
#
config.excluded_models = %w{ Subdomain SubdomainRequest}

# In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment.
# You can make this dynamic by providing a Proc object to be called on migrations.
# This object should yield either:
# - an array of strings representing each Tenant name.
# - a hash which keys are tenant names, and values custom db config
# (must contain all key/values required in database.yml)
#
# config.tenant_names = lambda{ Subdomain.pluck(:name) }
# config.tenant_names = ['tenant1', 'tenant2']
# config.tenant_names = {
# 'tenant1' => {
# adapter: 'postgresql',
# host: 'some_server',
# port: 5555,
# database: 'postgres' # this is not the name of the tenant's db
# # but the name of the database to connect to before creating the tenant's db
# # mandatory in postgresql
# },
# 'tenant2' => {
# adapter: 'postgresql',
# database: 'postgres' # this is not the name of the tenant's db
# # but the name of the database to connect to before creating the tenant's db
# # mandatory in postgresql
# }
# }
# config.tenant_names = lambda do
# Tenant.all.each_with_object({}) do |tenant, hash|
# hash[tenant.name] = tenant.db_configuration
# end
# end
#
config.tenant_names = lambda do
Subdomain.all.each_with_object({}) do |subdomain, hash|
hash[subdomain.name] = subdomain.db_configuration
# In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment.
# You can make this dynamic by providing a Proc object to be called on migrations.
# This object should yield either:
# - an array of strings representing each Tenant name.
# - a hash which keys are tenant names, and values custom db config
# (must contain all key/values required in database.yml)
#
# config.tenant_names = lambda{ Subdomain.pluck(:name) }
# config.tenant_names = ['tenant1', 'tenant2']
# config.tenant_names = {
# 'tenant1' => {
# adapter: 'postgresql',
# host: 'some_server',
# port: 5555,
# database: 'postgres' # this is not the name of the tenant's db
# # but the name of the database to connect to before creating the tenant's db
# # mandatory in postgresql
# },
# 'tenant2' => {
# adapter: 'postgresql',
# database: 'postgres' # this is not the name of the tenant's db
# # but the name of the database to connect to before creating the tenant's db
# # mandatory in postgresql
# }
# }
# config.tenant_names = lambda do
# Tenant.all.each_with_object({}) do |tenant, hash|
# hash[tenant.name] = tenant.db_configuration
# end
# end
#
config.tenant_names = lambda do
Subdomain.all.each_with_object({}) do |subdomain, hash|
hash[subdomain.name] = subdomain.db_configuration
end
end
end

# PostgreSQL:
# Specifies whether to use PostgreSQL schemas or create a new database per Tenant.
#
# MySQL:
# Specifies whether to switch databases by using `use` statement or re-establish connection.
#
# The default behaviour is true.
#
# config.use_schemas = true
# PostgreSQL:
# Specifies whether to use PostgreSQL schemas or create a new database per Tenant.
#
# MySQL:
# Specifies whether to switch databases by using `use` statement or re-establish connection.
#
# The default behaviour is true.
#
# config.use_schemas = true

#
# ==> PostgreSQL only options
#
# ==> PostgreSQL only options

# Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas.
# Use this when you are using some extra features in PostgreSQL that can't be represented in
# schema.rb, like materialized views etc. (only applies with use_schemas set to true).
# (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump)
#
# config.use_sql = false
# Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas.
# Use this when you are using some extra features in PostgreSQL that can't be represented in
# schema.rb, like materialized views etc. (only applies with use_schemas set to true).
# (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump)
#
# config.use_sql = false

# There are cases where you might want some schemas to always be in your search_path
# e.g when using a PostgreSQL extension like hstore.
# Any schemas added here will be available along with your selected Tenant.
#
# config.persistent_schemas = %w{ hstore }
# There are cases where you might want some schemas to always be in your search_path
# e.g when using a PostgreSQL extension like hstore.
# Any schemas added here will be available along with your selected Tenant.
#
# config.persistent_schemas = %w{ hstore }

# <== PostgreSQL only options
#
# <== PostgreSQL only options
#

# By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment
# to the tenant name to ensure there is no conflict between your environments.
# This is mainly for the benefit of your development and test environments.
# Uncomment the line below if you want to disable this behaviour in production.
#
# config.prepend_environment = !Rails.env.production?
# By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment
# to the tenant name to ensure there is no conflict between your environments.
# This is mainly for the benefit of your development and test environments.
# Uncomment the line below if you want to disable this behaviour in production.
#
# config.prepend_environment = !Rails.env.production?

# When using PostgreSQL schemas, the database dump will be namespaced, and
# apartment will substitute the default namespace (usually public) with the
# name of the new tenant when creating a new tenant. Some items must maintain
# a reference to the default namespace (ie public) - for instance, a default
# uuid generation. Uncomment the line below to create a list of namespaced
# items in the schema dump that should *not* have their namespace replaced by
# the new tenant
#
config.pg_excluded_names = ["uuid_generate_v4"]
# When using PostgreSQL schemas, the database dump will be namespaced, and
# apartment will substitute the default namespace (usually public) with the
# name of the new tenant when creating a new tenant. Some items must maintain
# a reference to the default namespace (ie public) - for instance, a default
# uuid generation. Uncomment the line below to create a list of namespaced
# items in the schema dump that should *not* have their namespace replaced by
# the new tenant
#
config.pg_excluded_names = ["uuid_generate_v4"]

# Specifies whether the database and schema (when using PostgreSQL schemas) will prepend in ActiveRecord log.
# Uncomment the line below if you want to enable this behavior.
#
# config.active_record_log = true
# Specifies whether the database and schema (when using PostgreSQL schemas) will prepend in ActiveRecord log.
# Uncomment the line below if you want to enable this behavior.
#
# config.active_record_log = true
end
end
# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that
# you want to switch to.
# Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
# "www"
# }

# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that
# you want to switch to.
# Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
# "www"
# }
# Rails.application.config.middleware.use Apartment::Elevators::Domain

# Rails.application.config.middleware.use Apartment::Elevators::Domain
Rails.application.config.middleware.use Apartment::Elevators::Generic,
Proc.new { |request|
hostname = request.host.split('.')[0]
Apartment.tenant_names.include?(hostname) ? hostname : 'public'
}
# Rails.application.config.middleware.use Apartment::Elevators::Subdomain

# Rails.application.config.middleware.use Apartment::Elevators::Subdomain

# plug in exclusions model here
Apartment::Elevators::Subdomain.excluded_subdomains = []
Rails.application.reloader.to_prepare do
Apartment::Elevators::Subdomain.excluded_subdomains = []
end
# Rails.application.config.middleware.use Apartment::Elevators::FirstSubdomain
# Rails.application.config.middleware.use Apartment::Elevators::Host
Loading