mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-31 03:09:06 -04:00
- Introduced `PhotoResource`, `PlantingResource`, and `SeedResource` to manage respective models. - Updated application configuration to include API base URL. - Modified production and test environments to set API base URL dynamically. - Removed outdated JSONAPI resources initializers and patches. - Refactored routes to use resourceful routing for API endpoints. - Updated request specs to reflect changes in API responses and relationships. - Added helper methods for generating related links in request specs.
95 lines
3.4 KiB
Ruby
95 lines
3.4 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.
|
|
config.x.api_base_url = ENV.fetch('API_BASE_URL', 'http://localhost:3000')
|
|
|
|
# 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"
|
|
|
|
Gibbon::API.api_key = ENV['GROWSTUFF_MAILCHIMP_APIKEY'] || 'notarealkey'
|
|
# API key can't be blank or tests fail
|
|
Gibbon::API.timeout = 10
|
|
Gibbon::API.throws_exceptions = false
|
|
config.newsletter_list_id = ENV.fetch('GROWSTUFF_MAILCHIMP_NEWSLETTER_ID', nil)
|
|
|
|
# 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
|