Files

91 lines
3.3 KiB
Ruby

# frozen_string_literal: true
require_relative 'boot'
require 'rails'
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
ENV['RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION'] = "true"
require 'openssl'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Growstuff
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 8.1
# Rails 7.1+ requires a coder for `serialize`.
# We set YAML as the default for compatibility with gems like Mexican Sofa.
config.active_record.default_column_serializer = YAML
I18n.config.enforce_available_locales = true
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'UTC'
config.active_record.default_timezone = :local
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone]
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
I18n.load_path += Dir[Rails.root.join("config/locales/*.{rb,yml}")]
I18n.default_locale = :en
# rails will fallback to config.i18n.default_locale translation
config.i18n.fallbacks = true
# rails will fallback to en, no matter what is set as config.i18n.default_locale
config.i18n.fallbacks = [:en]
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Where the API says it lives, for the links in its responses.
# In a Codespace that is the forwarded address, as for config.host in the development environment.
default_api_base_url = ENV['CODESPACE_NAME'] ? "https://#{ENV['CODESPACE_NAME']}-3000.app.github.dev" : 'http://localhost:3000'
config.x.api_base_url = ENV.fetch('API_BASE_URL', default_api_base_url)
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# The Sass sources are compiled by `yarn build:css` into app/assets/builds,
# so Propshaft should not serve them as they are.
config.assets.excluded_paths = [Rails.root.join('app/assets/stylesheets')]
config.generators do |g|
g.template_engine :haml
g.view_specs false
g.controller_specs false
g.helper false
g.stylesheets false
g.javascripts false
end
# Growstuff-specific configuration variables
config.currency = 'AUD'
config.bot_email = ENV.fetch('GROWSTUFF_EMAIL', nil)
config.user_agent = 'Growstuff'
config.user_agent_email = "info@growstuff.org"
# config.active_record.raise_in_transactional_callbacks = true
config.middleware.insert_before 0, Rack::Attack
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '/api/v1/*', headers: :any, methods: %i(get options)
end
end
end
end