apidae 1.4.15 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/apidae/objects_controller.rb +7 -0
  3. data/app/controllers/apidae/projects_controller.rb +1 -7
  4. data/app/models/apidae/obj.rb +26 -0
  5. data/app/models/apidae/selection.rb +0 -3
  6. data/app/views/apidae/objects/search.html.erb +49 -0
  7. data/config/initializers/search.rb +23 -0
  8. data/config/routes.rb +2 -4
  9. data/db/migrate/20250129190137_create_pg_search_documents.rb +17 -0
  10. data/db/migrate/20250130110941_add_columns_to_pg_search_documents.rb +10 -0
  11. data/db/migrate/20250130120941_add_tsv_column_to_pg_search_documents.rb +22 -0
  12. data/db/migrate/20250130152441_add_gin_index_to_pg_search_documents.rb +7 -0
  13. data/lib/apidae/version.rb +1 -1
  14. data/test/dummy/bin/rails +3 -3
  15. data/test/dummy/bin/rake +2 -2
  16. data/test/dummy/bin/setup +21 -13
  17. data/test/dummy/config/application.rb +21 -13
  18. data/test/dummy/config/boot.rb +2 -4
  19. data/test/dummy/config/cable.yml +10 -0
  20. data/test/dummy/config/environment.rb +1 -1
  21. data/test/dummy/config/environments/development.rb +53 -19
  22. data/test/dummy/config/environments/production.rb +56 -36
  23. data/test/dummy/config/environments/test.rb +44 -19
  24. data/test/dummy/config/initializers/apidae.rb +7 -5
  25. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  26. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -2
  27. data/test/dummy/config/initializers/inflections.rb +4 -4
  28. data/test/dummy/config/initializers/new_framework_defaults_7_2.rb +70 -0
  29. data/test/dummy/config/initializers/permissions_policy.rb +13 -0
  30. data/test/dummy/config/puma.rb +34 -0
  31. data/test/dummy/config/storage.yml +34 -0
  32. data/test/dummy/db/migrate/20250129172254_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
  33. data/test/dummy/db/migrate/20250129172255_create_active_storage_variant_records.active_storage.rb +27 -0
  34. data/test/dummy/db/migrate/20250129172256_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +8 -0
  35. data/test/dummy/public/404.html +6 -6
  36. data/test/dummy/public/406-unsupported-browser.html +66 -0
  37. data/test/dummy/public/422.html +6 -6
  38. data/test/dummy/public/500.html +6 -6
  39. data/test/dummy/public/icon.png +0 -0
  40. data/test/dummy/public/icon.svg +3 -0
  41. data/test/dummy/public/robots.txt +1 -0
  42. metadata +53 -13
  43. data/test/dummy/app/assets/config/manifest.js +0 -1
  44. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  45. data/test/dummy/config/initializers/assets.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 829fbcc39fd6110c0bbe6900004d1ed3e0efc2a0a345e1c2e0addd151b045d3f
4
- data.tar.gz: e8501491443543d72b6fc710ae0a1bcbe18cdaaa40df2942008d1cbc2b0dd625
3
+ metadata.gz: d2e758f9b9ec206503bf49f0b007a703e4b99d0092294b0f28dd563bfd7e0d3c
4
+ data.tar.gz: 6504e5a2b17c7fb7ac75ce662b8f9273d932ada2219be41d557a461be6b3aca2
5
5
  SHA512:
6
- metadata.gz: 5fae148c4eec799645b90c2be7dc211d76211e4a516ab4cbe960d6e436b501462b792670058441533d296c840de9ddf28471fd246913b902e6862c66dfda1844
7
- data.tar.gz: 4e237b2628166c531857663f7cc245d8b9bf3998d9702325fde9f9a076bc47159894f9b258b2c2328cfb0678fa20c4464f4921d5f674c341f186a0a76c1418d2
6
+ metadata.gz: 7a9348ceed64ae7dfa7476e4a444eff649cca4148b5329305e9057e8fcbbae396308cf8e99119b1cbe0518935e254b7471ab0234250215454014ed23c3022325
7
+ data.tar.gz: f0e3ee4e7945eec4fbb642a5838d29b81fb4c9a6ed34272b781180c30394d79b5f5ab3dc9910b25f0a79061b4058fb5364a50f2ae3a9327e883cc8cd89002d75
@@ -78,6 +78,13 @@ module Apidae
78
78
  end
79
79
  end
80
80
 
81
+ def search
82
+ user_selections = Project.where(apidae_id: apidae_user.apidae_projects_ids).map {|p| p.apidae_selection_ids}.flatten.uniq
83
+ @results = PgSearch::Document.tsv_search(params[:query])
84
+ .joins("INNER JOIN apidae_selection_objects AS aso ON (aso.apidae_object_id = pg_search_documents.searchable_id) AND pg_search_documents.searchable_type = 'Apidae::Obj'")
85
+ .where("aso.apidae_selection_id IN (?)", user_selections)
86
+ end
87
+
81
88
  private
82
89
  def set_object
83
90
  @obj = Obj.find(params[:id])
@@ -3,9 +3,7 @@ require_dependency "apidae/application_controller"
3
3
  module Apidae
4
4
  class ProjectsController < ApplicationController
5
5
  before_action :set_project, only: [:edit, :update, :destroy]
6
- skip_before_action :check_user_data!, only: [:create, :realtime]
7
- skip_before_action :verify_authenticity_token, only: [:realtime]
8
- skip_before_action Rails.application.config.apidae_auth, only: [:realtime]
6
+ skip_before_action :check_user_data!, only: [:create]
9
7
 
10
8
  def index
11
9
  if user_is_admin?
@@ -49,10 +47,6 @@ module Apidae
49
47
  redirect_to request.referrer, notice: 'Le projet a bien été supprimé.'
50
48
  end
51
49
 
52
- def realtime
53
- Rails.logger.info "realtime webhook : #{params.to_unsafe_h}"
54
- end
55
-
56
50
  private
57
51
 
58
52
  def set_project
@@ -1,5 +1,10 @@
1
+ require 'pg_search'
2
+
1
3
  module Apidae
2
4
  class Obj < ActiveRecord::Base
5
+ include PgSearch::Model
6
+ multisearchable against: [:title, :short_desc, :town_search, :criteria_search],
7
+ additional_attributes: -> (o) { { searchable_fields: o.searchable_fields } }
3
8
 
4
9
  belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code, optional: true
5
10
  has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_object_id
@@ -139,6 +144,27 @@ module Apidae
139
144
  self
140
145
  end
141
146
 
147
+ def town_search
148
+ town&.label
149
+ end
150
+
151
+ def criteria_search
152
+ ([SUBTYPES.dig(apidae_subtype&.to_i, :label)] + ref_search(payment_methods, PAYMENT) +
153
+ ref_search(categories, CATEGORIES) + ref_search(themes, THEMES) + ref_search(labels, LABELS) +
154
+ ref_search(chains, CHAINS) + ref_search(classification, CLASSIFICATION) + ref_search(services, SERVICES) +
155
+ ref_search(equipments, EQUIPMENTS) + ref_search(comfort, COMFORT) + ref_search(activities, ACTIVITIES) +
156
+ ref_search(challenged, CHALLENGED) + ref_search(audience, AUDIENCE) + ref_search(promo, PROMO) +
157
+ ref_search(environments, ENVIRONMENTS) + ref_search(products, PRODUCTS) + ref_search(internal, INTERNALS)).compact.uniq
158
+ end
159
+
160
+ def ref_search(ref_values, ref_list, label_key = :label)
161
+ (ref_values || []).map {|r| ref_list.dig(r, label_key)}
162
+ end
163
+
164
+ def searchable_fields
165
+ {s_title: title, s_desc: short_desc, s_external_id: apidae_id, s_type: apidae_type, s_picture: main_picture}
166
+ end
167
+
142
168
  def dig(*keys)
143
169
  root_key, *nested_keys = keys
144
170
  root_val = self.send(root_key)
@@ -40,9 +40,6 @@ module Apidae
40
40
 
41
41
  removed_ids = Obj.where(apidae_id: removed).map {|o| o.id}
42
42
  SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
43
- if added.any? || removed.any? || (apidae_sel.objects.maximum(:updated_at) > apidae_sel.updated_at)
44
- apidae_sel.touch
45
- end
46
43
  end
47
44
 
48
45
  def cleanup
@@ -0,0 +1,49 @@
1
+ <%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
2
+ <div id="apidae_header" class="<%= styles[:header] %>">
3
+ <%= link_to 'Importer un objet', apidae.new_object_path(selection_apidae_id: nil), class: styles[:objects] %>
4
+ <%= link_to 'Retour', root_path, class: styles[:back] %>
5
+ <h1 class="<%= styles[:h1] %>">Apidae - Rechercher des objets</h1>
6
+ </div>
7
+ <div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
8
+ <div id="apidae_search_form" class="<%= styles[:body] %>">
9
+ <%= form_tag(apidae.search_objects_path, method: :get) do %>
10
+ <%= text_field_tag 'query', @query, placeholder: 'Recherche par mots-clés' %>
11
+ <%= submit_tag 'Rechercher' %>
12
+ <% end %>
13
+ <br/>
14
+ </div>
15
+ <div id="apidae_imports_panel" class="<%= styles[:body] %>">
16
+ <table id="apidae_objects" class="<%= styles[:table] %>">
17
+ <thead class="<%= styles[:table_head] %>">
18
+ <tr>
19
+ <th>Titre</th>
20
+ <th>Identifiant</th>
21
+ <th>Type</th>
22
+ <th>Mise à jour</th>
23
+ <th></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody class="<%= styles[:table_body] %>">
27
+ <% @results.each do |object| %>
28
+ <tr>
29
+ <td><%= object.searchable_title %></td>
30
+ <td><%= object.searchable_id %></td>
31
+ <td><%= object.searchable_category %></td>
32
+ <td><%= object.updated_at.strftime('Le %d/%m/%Y à %H:%M') if object.updated_at %></td>
33
+ <td><%= link_to 'Rafraîchir', apidae.refresh_object_path(object), method: :post,
34
+ data: {confirm: 'Voulez-vous vraiment rafraîchir cet objet ? Les données existantes seront écrasées.'} %></td>
35
+ </tr>
36
+ <% end %>
37
+ <% if @results.empty? %>
38
+ <tr>
39
+ <td colspan="5">Aucun objet importé pour le moment.</td>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
44
+ </div>
45
+ </div>
46
+ <% end %>
47
+ <script>
48
+
49
+ </script>
@@ -0,0 +1,23 @@
1
+ Rails.application.config.after_initialize do
2
+ require 'pg_search'
3
+
4
+ PgSearch.multisearch_options = {
5
+ using: {tsearch: {dictionary: 'fr'}},
6
+ ignoring: :accents
7
+ }
8
+
9
+ PgSearch::Document.pg_search_scope(:tsv_search, lambda { |*args|
10
+ {
11
+ query: args.first,
12
+ against: [:content],
13
+ ignoring: :accents,
14
+ using: {
15
+ tsearch: {
16
+ dictionary: 'fr',
17
+ prefix: true,
18
+ tsvector_column: ["tsv_content"]
19
+ }
20
+ }
21
+ }
22
+ })
23
+ end
data/config/routes.rb CHANGED
@@ -2,6 +2,7 @@ Apidae::Engine.routes.draw do
2
2
 
3
3
  resources :objects, only: [:index, :show, :new, :create], path: 'objets' do
4
4
  post 'refresh', on: :member
5
+ get 'search', on: :collection
5
6
  end
6
7
 
7
8
  resources :selections, only: [:index] do
@@ -11,10 +12,7 @@ Apidae::Engine.routes.draw do
11
12
  end
12
13
  end
13
14
  resources :references, only: [:index]
14
- resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], path: 'projets' do
15
- post 'realtime', on: :collection
16
- end
17
-
15
+ resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], path: 'projets'
18
16
 
19
17
  match 'import/callback', via: :post, to: 'import#callback'
20
18
  match 'import/run', via: :post, to: 'import#run'
@@ -0,0 +1,17 @@
1
+ class CreatePgSearchDocuments < ActiveRecord::Migration[7.2]
2
+ def up
3
+ say_with_time("Creating table for pg_search multisearch") do
4
+ create_table :pg_search_documents do |t|
5
+ t.text :content
6
+ t.belongs_to :searchable, polymorphic: true, index: true
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
11
+
12
+ def down
13
+ say_with_time("Dropping table for pg_search multisearch") do
14
+ drop_table :pg_search_documents
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ class AddColumnsToPgSearchDocuments < ActiveRecord::Migration[7.2]
2
+ def up
3
+ # extra attributes columns
4
+ add_column :pg_search_documents, :searchable_fields, :jsonb
5
+ end
6
+
7
+ def down
8
+ remove_column :pg_search_documents, :searchable_fields, if_exists: true
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ class AddTsvColumnToPgSearchDocuments < ActiveRecord::Migration[7.2]
2
+ def up
3
+ execute <<-SQL
4
+ CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
5
+ ALTER TEXT SEARCH CONFIGURATION fr
6
+ ALTER MAPPING FOR hword, hword_part, word
7
+ WITH unaccent, french_stem;
8
+
9
+ ALTER TABLE pg_search_documents
10
+ ADD COLUMN tsv_content tsvector GENERATED ALWAYS AS (
11
+ to_tsvector('fr', coalesce(content, ''))
12
+ ) STORED;
13
+ SQL
14
+ end
15
+
16
+ def down
17
+ execute <<-SQL
18
+ DROP TEXT SEARCH CONFIGURATION IF EXISTS fr;
19
+ ALTER TABLE pg_search_documents DROP COLUMN IF EXISTS tsv_content;
20
+ SQL
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ class AddGinIndexToPgSearchDocuments < ActiveRecord::Migration[7.2]
2
+ disable_ddl_transaction!
3
+
4
+ def change
5
+ add_index :pg_search_documents, :tsv_content, using: :gin, algorithm: :concurrently
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "1.4.15"
2
+ VERSION = "2.0.0"
3
3
  end
data/test/dummy/bin/rails CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
data/test/dummy/bin/rake CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
2
+ require_relative "../config/boot"
3
+ require "rake"
4
4
  Rake.application.run
data/test/dummy/bin/setup CHANGED
@@ -1,29 +1,37 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
2
+ require "fileutils"
3
3
 
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+ APP_NAME = "dummy"
6
6
 
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
7
+ def system!(*args)
8
+ system(*args, exception: true)
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
10
15
 
11
16
  puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
14
19
 
15
20
  # puts "\n== Copying sample files =="
16
21
  # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
18
23
  # end
19
24
 
20
25
  puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
26
+ system! "bin/rails db:prepare"
22
27
 
23
28
  puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
29
+ system! "bin/rails log:clear tmp:clear"
26
30
 
27
31
  puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
32
+ system! "bin/rails restart"
33
+
34
+ # puts "\n== Configuring puma-dev =="
35
+ # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
36
+ # system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
29
37
  end
@@ -1,24 +1,32 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative "boot"
2
2
 
3
- require 'rails/all'
3
+ require "rails/all"
4
4
 
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
5
7
  Bundler.require(*Rails.groups)
6
- require "apidae"
7
8
 
8
9
  module Dummy
9
10
  class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 5.0
13
13
 
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
14
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
15
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
16
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
17
+ config.autoload_lib(ignore: %w[assets tasks])
18
+
19
+ # Configuration for the application, engines, and railties goes here.
20
+ #
21
+ # These settings can be overridden in specific environments using the files
22
+ # in config/environments, which are processed later.
23
+ #
24
+ # config.time_zone = "Central Time (US & Canada)"
25
+ # config.eager_load_paths << Rails.root.join("extras")
17
26
 
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
27
  config.apidae_auth = :dummy_auth
28
+
29
+ # Use sql schema format
30
+ config.active_record.schema_format = :sql
22
31
  end
23
32
  end
24
-
@@ -1,5 +1,3 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
3
2
 
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: dummy_production
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require_relative "application"
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -1,41 +1,75 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
6
8
  # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
9
+ config.enable_reloading = true
8
10
 
9
11
  # Do not eager load code on boot.
10
12
  config.eager_load = false
11
13
 
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable server timing.
18
+ config.server_timing = true
19
+
20
+ # Enable/disable caching. By default caching is disabled.
21
+ # Run rails dev:cache to toggle caching.
22
+ if Rails.root.join("tmp/caching-dev.txt").exist?
23
+ config.action_controller.perform_caching = true
24
+ config.action_controller.enable_fragment_cache_logging = true
25
+
26
+ config.cache_store = :memory_store
27
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
28
+ else
29
+ config.action_controller.perform_caching = false
30
+
31
+ config.cache_store = :null_store
32
+ end
33
+
34
+ # Store uploaded files on the local file system (see config/storage.yml for options).
35
+ config.active_storage.service = :local
15
36
 
16
37
  # Don't care if the mailer can't send.
17
38
  config.action_mailer.raise_delivery_errors = false
18
39
 
40
+ # Disable caching for Action Mailer templates even if Action Controller
41
+ # caching is enabled.
42
+ config.action_mailer.perform_caching = false
43
+
44
+ config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
45
+
19
46
  # Print deprecation notices to the Rails logger.
20
47
  config.active_support.deprecation = :log
21
48
 
49
+ # Raise exceptions for disallowed deprecations.
50
+ config.active_support.disallowed_deprecation = :raise
51
+
52
+ # Tell Active Support which deprecation messages to disallow.
53
+ config.active_support.disallowed_deprecation_warnings = []
54
+
22
55
  # Raise an error on page load if there are pending migrations.
23
56
  config.active_record.migration_error = :page_load
24
57
 
25
- # Debug mode disables concatenation and preprocessing of assets.
26
- # This option may cause significant delays in view rendering with a large
27
- # number of complex assets.
28
- config.assets.debug = true
58
+ # Highlight code that triggered database queries in logs.
59
+ config.active_record.verbose_query_logs = true
60
+
61
+ # Highlight code that enqueued background job in logs.
62
+ config.active_job.verbose_enqueue_logs = true
63
+
64
+ # Raises error for missing translations.
65
+ # config.i18n.raise_on_missing_translations = true
29
66
 
30
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
- # yet still be able to expire them through the digest params.
32
- config.assets.digest = true
67
+ # Annotate rendered view with file names.
68
+ config.action_view.annotate_rendered_view_with_filenames = true
33
69
 
34
- # Adds additional error checking when serving assets at runtime.
35
- # Checks for improperly declared sprockets dependencies.
36
- # Raises helpful error messages.
37
- config.assets.raise_runtime_errors = true
70
+ # Uncomment if you wish to allow Action Cable access from any origin.
71
+ # config.action_cable.disable_request_forgery_protection = true
38
72
 
39
- # Raises error for missing translations
40
- # config.action_view.raise_on_missing_translations = true
73
+ # Raise error when a before_action's only/except options reference missing actions.
74
+ config.action_controller.raise_on_missing_callback_actions = true
41
75
  end
@@ -1,8 +1,10 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
4
6
  # Code is not reloaded between requests.
5
- config.cache_classes = true
7
+ config.enable_reloading = false
6
8
 
7
9
  # Eager load code on boot. This eager loads most of Rails and
8
10
  # your application in memory, allowing both threaded web servers
@@ -11,54 +13,64 @@ Rails.application.configure do
11
13
  config.eager_load = true
12
14
 
13
15
  # Full error reports are disabled and caching is turned on.
14
- config.consider_all_requests_local = false
16
+ config.consider_all_requests_local = false
15
17
  config.action_controller.perform_caching = true
16
18
 
17
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
- # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like
20
- # NGINX, varnish or squid.
21
- # config.action_dispatch.rack_cache = true
19
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
20
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
21
+ # config.require_master_key = true
22
22
 
23
- # Disable serving static files from the `/public` folder by default since
24
- # Apache or NGINX already handles this.
25
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
23
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24
+ # config.public_file_server.enabled = false
26
25
 
27
- # Compress JavaScripts and CSS.
28
- config.assets.js_compressor = :uglifier
29
- # config.assets.css_compressor = :sass
26
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
27
+ # config.asset_host = "http://assets.example.com"
30
28
 
31
- # Do not fallback to assets pipeline if a precompiled asset is missed.
32
- config.assets.compile = false
29
+ # Specifies the header that your server uses for sending files.
30
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
31
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
33
32
 
34
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
- # yet still be able to expire them through the digest params.
36
- config.assets.digest = true
33
+ # Store uploaded files on the local file system (see config/storage.yml for options).
34
+ config.active_storage.service = :local
37
35
 
38
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
36
+ # Mount Action Cable outside main process or domain.
37
+ # config.action_cable.mount_path = nil
38
+ # config.action_cable.url = "wss://example.com/cable"
39
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
39
40
 
40
- # Specifies the header that your server uses for sending files.
41
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
42
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
43
+ # config.assume_ssl = true
43
44
 
44
45
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
- # config.force_ssl = true
46
+ config.force_ssl = true
47
+
48
+ # Skip http-to-https redirect for the default health check endpoint.
49
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
46
50
 
47
- # Use the lowest log level to ensure availability of diagnostic information
48
- # when problems arise.
49
- config.log_level = :debug
51
+ # Log to STDOUT by default
52
+ config.logger = ActiveSupport::Logger.new(STDOUT)
53
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
54
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
50
55
 
51
56
  # Prepend all log lines with the following tags.
52
- # config.log_tags = [ :subdomain, :uuid ]
57
+ config.log_tags = [ :request_id ]
53
58
 
54
- # Use a different logger for distributed setups.
55
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
59
+ # "info" includes generic and useful information about system operation, but avoids logging too much
60
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
61
+ # want to log everything, set the level to "debug".
62
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
56
63
 
57
64
  # Use a different cache store in production.
58
65
  # config.cache_store = :mem_cache_store
59
66
 
60
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
- # config.action_controller.asset_host = 'http://assets.example.com'
67
+ # Use a real queuing backend for Active Job (and separate queues per environment).
68
+ # config.active_job.queue_adapter = :resque
69
+ # config.active_job.queue_name_prefix = "dummy_production"
70
+
71
+ # Disable caching for Action Mailer templates even if Action Controller
72
+ # caching is enabled.
73
+ config.action_mailer.perform_caching = false
62
74
 
63
75
  # Ignore bad email addresses and do not raise email delivery errors.
64
76
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -68,12 +80,20 @@ Rails.application.configure do
68
80
  # the I18n.default_locale when a translation cannot be found).
69
81
  config.i18n.fallbacks = true
70
82
 
71
- # Send deprecation notices to registered listeners.
72
- config.active_support.deprecation = :notify
73
-
74
- # Use default logging formatter so that PID and timestamp are not suppressed.
75
- config.log_formatter = ::Logger::Formatter.new
83
+ # Don't log any deprecations.
84
+ config.active_support.report_deprecations = false
76
85
 
77
86
  # Do not dump schema after migrations.
78
87
  config.active_record.dump_schema_after_migration = false
88
+
89
+ # Only use :id for inspections in production.
90
+ config.active_record.attributes_for_inspect = [ :id ]
91
+
92
+ # Enable DNS rebinding protection and other `Host` header attacks.
93
+ # config.hosts = [
94
+ # "example.com", # Allow requests from example.com
95
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
96
+ # ]
97
+ # Skip DNS rebinding protection for the default health check endpoint.
98
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
79
99
  end