acts_as_graph_diagram 0.1.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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +178 -0
  4. data/Rakefile +5 -0
  5. data/bin/test +7 -0
  6. data/lib/acts_as_graph_diagram/edge_scopes.rb +23 -0
  7. data/lib/acts_as_graph_diagram/node/graph_calculator.rb +129 -0
  8. data/lib/acts_as_graph_diagram/node.rb +120 -0
  9. data/lib/acts_as_graph_diagram/railtie.rb +11 -0
  10. data/lib/acts_as_graph_diagram/version.rb +5 -0
  11. data/lib/acts_as_graph_diagram.rb +12 -0
  12. data/lib/generators/USAGE +5 -0
  13. data/lib/generators/acts_as_graph_diagram_generator.rb +30 -0
  14. data/lib/generators/templates/migration.rb +21 -0
  15. data/lib/generators/templates/model.rb +24 -0
  16. data/test/acts_as_graph_diagram_test.rb +44 -0
  17. data/test/dummy/Rakefile +39 -0
  18. data/test/dummy/app/assets/config/manifest.js +3 -0
  19. data/test/dummy/app/assets/images/.keep +0 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  21. data/test/dummy/app/channels/application_cable/channel.rb +6 -0
  22. data/test/dummy/app/channels/application_cable/connection.rb +6 -0
  23. data/test/dummy/app/controllers/application_controller.rb +4 -0
  24. data/test/dummy/app/controllers/concerns/.keep +0 -0
  25. data/test/dummy/app/controllers/gods_controller.rb +67 -0
  26. data/test/dummy/app/helpers/application_helper.rb +4 -0
  27. data/test/dummy/app/helpers/gods_helper.rb +4 -0
  28. data/test/dummy/app/javascript/application.js +94 -0
  29. data/test/dummy/app/jobs/application_job.rb +9 -0
  30. data/test/dummy/app/mailers/application_mailer.rb +6 -0
  31. data/test/dummy/app/models/application_record.rb +5 -0
  32. data/test/dummy/app/models/concerns/.keep +0 -0
  33. data/test/dummy/app/models/edge.rb +24 -0
  34. data/test/dummy/app/models/god.rb +14 -0
  35. data/test/dummy/app/views/gods/_form.html.erb +22 -0
  36. data/test/dummy/app/views/gods/_god.html.erb +16 -0
  37. data/test/dummy/app/views/gods/edit.html.erb +6 -0
  38. data/test/dummy/app/views/gods/index.html.erb +35 -0
  39. data/test/dummy/app/views/gods/new.html.erb +5 -0
  40. data/test/dummy/app/views/gods/show.html.erb +9 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  42. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/test/dummy/bin/importmap +5 -0
  45. data/test/dummy/bin/rails +6 -0
  46. data/test/dummy/bin/rake +6 -0
  47. data/test/dummy/bin/setup +35 -0
  48. data/test/dummy/config/application.rb +23 -0
  49. data/test/dummy/config/boot.rb +7 -0
  50. data/test/dummy/config/cable.yml +10 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +7 -0
  53. data/test/dummy/config/environments/development.rb +71 -0
  54. data/test/dummy/config/environments/production.rb +89 -0
  55. data/test/dummy/config/environments/test.rb +62 -0
  56. data/test/dummy/config/importmap.rb +43 -0
  57. data/test/dummy/config/initializers/content_security_policy.rb +26 -0
  58. data/test/dummy/config/initializers/filter_parameter_logging.rb +10 -0
  59. data/test/dummy/config/initializers/inflections.rb +17 -0
  60. data/test/dummy/config/initializers/permissions_policy.rb +12 -0
  61. data/test/dummy/config/locales/en.yml +33 -0
  62. data/test/dummy/config/puma.rb +45 -0
  63. data/test/dummy/config/routes.rb +11 -0
  64. data/test/dummy/config/storage.yml +34 -0
  65. data/test/dummy/config.ru +8 -0
  66. data/test/dummy/db/migrate/20220606102242_create_gods.rb +11 -0
  67. data/test/dummy/db/migrate/20220612090334_acts_as_graph_diagram_migration.rb +21 -0
  68. data/test/dummy/db/schema.rb +35 -0
  69. data/test/dummy/db/seeds.rb +53 -0
  70. data/test/dummy/lib/assets/.keep +0 -0
  71. data/test/dummy/log/.keep +0 -0
  72. data/test/dummy/public/404.html +67 -0
  73. data/test/dummy/public/422.html +67 -0
  74. data/test/dummy/public/500.html +66 -0
  75. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  76. data/test/dummy/public/apple-touch-icon.png +0 -0
  77. data/test/dummy/public/favicon.ico +0 -0
  78. data/test/dummy/test/controllers/gods_controller_test.rb +50 -0
  79. data/test/dummy/test/system/gods_test.rb +43 -0
  80. data/test/fixtures/edges.yml +111 -0
  81. data/test/fixtures/gods.yml +81 -0
  82. data/test/test_helper.rb +18 -0
  83. metadata +434 -0
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative 'config/application'
7
+
8
+ Rails.application.load_tasks
9
+
10
+ # Аcknowledgments:
11
+ # Generate Rails test fixtures yaml from database dump | Yi Zeng’s Blog https://yizeng.me/2017/07/16/generate-rails-test-fixtures-yaml-from-database-dump/
12
+
13
+ namespace :db do
14
+ desc 'Convert development DB to Rails test fixtures'
15
+ task to_fixtures: :environment do
16
+ TABLES_TO_SKIP = %w[ar_internal_metadata delayed_jobs schema_info schema_migrations].freeze
17
+
18
+ begin
19
+ ActiveRecord::Base.establish_connection
20
+ ActiveRecord::Base.connection.tables.each do |table_name|
21
+ next if TABLES_TO_SKIP.include?(table_name)
22
+
23
+ conter = '000'
24
+ file_path = "#{Rails.root}/../fixtures/#{table_name}.yml"
25
+ File.open(file_path, 'w') do |file|
26
+ rows = ActiveRecord::Base.connection.select_all("SELECT * FROM #{table_name}")
27
+ data = rows.each_with_object({}) do |record, hash|
28
+ suffix = record['id'].blank? ? conter.succ! : record['id']
29
+ hash["#{table_name.singularize}_#{suffix}"] = record
30
+ end
31
+ puts "Writing table '#{table_name}' to '#{file_path}'"
32
+ file.write(data.to_yaml)
33
+ end
34
+ end
35
+ ensure
36
+ ActiveRecord::Base.connection&.close
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
3
+ //= link_tree ../../javascript .js
File without changes
@@ -0,0 +1 @@
1
+ /* Application styles */
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Channel < ActionCable::Channel::Base
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Connection < ActionCable::Connection::Base
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
File without changes
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ class GodsController < ApplicationController
4
+ before_action :set_god, only: %i[show edit update destroy]
5
+
6
+ # GET /data_network
7
+ def data_network
8
+ render json: { 'nodes' => God.all.pluck(:id, :name)
9
+ .map { |x| Hash[id: x[0], name: x[1]] },
10
+ 'links' => Edge.all.pluck(:destination_id, :departure_id)
11
+ .map { |x| Hash[target: x[0], source: x[1]] } }
12
+ end
13
+
14
+ # GET /gods
15
+ def index
16
+ @gods = God.all
17
+ end
18
+
19
+ # GET /gods/1
20
+ def show; end
21
+
22
+ # GET /gods/new
23
+ def new
24
+ @god = God.new
25
+ end
26
+
27
+ # GET /gods/1/edit
28
+ def edit; end
29
+
30
+ # POST /gods
31
+ def create
32
+ @god = God.new(god_params)
33
+
34
+ if @god.save
35
+ redirect_to @god, notice: 'God was successfully created.'
36
+ else
37
+ render :new
38
+ end
39
+ end
40
+
41
+ # PATCH/PUT /gods/1
42
+ def update
43
+ if @god.update(god_params)
44
+ redirect_to @god, notice: 'God was successfully updated.'
45
+ else
46
+ render :edit
47
+ end
48
+ end
49
+
50
+ # DELETE /gods/1
51
+ def destroy
52
+ @god.destroy
53
+ redirect_to gods_url, notice: 'God was successfully destroyed.'
54
+ end
55
+
56
+ private
57
+
58
+ # Use callbacks to share common setup or constraints between actions.
59
+ def set_god
60
+ @god = God.find(params[:id])
61
+ end
62
+
63
+ # Only allow a list of trusted parameters through.
64
+ def god_params
65
+ params.require(:god).permit(:name)
66
+ end
67
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GodsHelper
4
+ end
@@ -0,0 +1,94 @@
1
+ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2
+ import "@hotwired/turbo-rails"
3
+
4
+ import * as d3 from "d3";
5
+
6
+ // See Force layout | D3 in Depth https://www.d3indepth.com/force-layout/
7
+
8
+ const svg = d3.select("svg"),
9
+ width = +svg.attr("width"),
10
+ height = +svg.attr("height");
11
+
12
+ const simulation = d3.forceSimulation()
13
+ .force("link",
14
+ d3.forceLink()
15
+ .distance(function (_d) {
16
+ return 100;
17
+ })
18
+ .strength(0.1)
19
+ .id(function (d) {
20
+ return d.id;
21
+ }))
22
+ .force("charge", d3.forceManyBody())
23
+ .force("center", d3.forceCenter(width / 2, height / 2));
24
+
25
+ d3.json("http://127.0.0.1:3000/data_network").then(function (graph) {
26
+ const link = svg
27
+ .append("g")
28
+ .attr("class", "links")
29
+ .selectAll("line")
30
+ .data(graph.links)
31
+ .enter()
32
+ .append("line")
33
+ .style("stroke", "#aaa");
34
+
35
+ const node = svg
36
+ .append("g")
37
+ .attr("class", "nodes")
38
+ .selectAll("circle")
39
+ .data(graph.nodes)
40
+ .enter()
41
+ .append("circle")
42
+ .attr("r", 6)
43
+
44
+ const label = svg
45
+ .append("g")
46
+ .attr("class", "labels")
47
+ .selectAll("text")
48
+ .data(graph.nodes)
49
+ .enter()
50
+ .append("text")
51
+ .attr("class", "label")
52
+ .text(function (d) {
53
+ return d.name;
54
+ });
55
+
56
+ simulation
57
+ .nodes(graph.nodes)
58
+ .on("tick", ticked);
59
+
60
+ simulation.force("link")
61
+ .links(graph.links);
62
+
63
+ function ticked() {
64
+ link
65
+ .attr("x1", function (d) {
66
+ return d.source.x;
67
+ })
68
+ .attr("y1", function (d) {
69
+ return d.source.y;
70
+ })
71
+ .attr("x2", function (d) {
72
+ return d.target.x;
73
+ })
74
+ .attr("y2", function (d) {
75
+ return d.target.y;
76
+ });
77
+
78
+ node
79
+ .attr("cx", function (d) {
80
+ return d.x;
81
+ })
82
+ .attr("cy", function (d) {
83
+ return d.y;
84
+ });
85
+
86
+ label
87
+ .attr("x", function (d) {
88
+ return d.x + 8;
89
+ })
90
+ .attr("y", function (d) {
91
+ return d.y + 3;
92
+ });
93
+ }
94
+ });
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationJob < ActiveJob::Base
4
+ # Automatically retry jobs that encountered a deadlock
5
+ # retry_on ActiveRecord::Deadlocked
6
+
7
+ # Most jobs are safe to ignore if the underlying records are no longer available
8
+ # discard_on ActiveJob::DeserializationError
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ primary_abstract_class
5
+ end
File without changes
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # == Schema Information
4
+ #
5
+ # Table name: edges
6
+ #
7
+ # id :integer not null, primary key
8
+ # comment :string default("")
9
+ # cost :integer default(0)
10
+ # directed :boolean default(TRUE)
11
+ # destination_type :string
12
+ # destination_id :integer
13
+ # departure_type :string
14
+ # departure_id :integer
15
+ # created_at :datetime
16
+ # updated_at :datetime
17
+ #
18
+ class Edge < ActiveRecord::Base
19
+ extend ActsAsGraphDiagram::Node
20
+ include ActsAsGraphDiagram::EdgeScopes
21
+
22
+ belongs_to :destination, polymorphic: true, optional: true
23
+ belongs_to :departure, polymorphic: true, optional: true
24
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # == Schema Information
4
+ #
5
+ # Table name: gods
6
+ #
7
+ # id :integer not null, primary key
8
+ # name :string not null
9
+ # created_at :datetime not null
10
+ # updated_at :datetime not null
11
+ #
12
+ class God < ActiveRecord::Base
13
+ acts_as_node
14
+ end
@@ -0,0 +1,22 @@
1
+ <%= form_with(model: god) do |form| %>
2
+ <% if god.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(god.errors.count, "error") %> prohibited this god from being saved:</h2>
5
+
6
+ <ul>
7
+ <% god.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.label :name, style: "display: block" %>
16
+ <%= form.text_field :name %>
17
+ </div>
18
+
19
+ <div class="actions">
20
+ <%= form.submit %>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <div id="<%= dom_id god %>">
2
+ <p>
3
+ <strong>Id:</strong>
4
+ <%= god.id %>
5
+ </p>
6
+
7
+ <p>
8
+ <strong>Name:</strong>
9
+ <%= god.name %>
10
+ </p>
11
+
12
+ <p>
13
+ <strong>Created At:</strong>
14
+ <%= god.created_at %>
15
+ </p>
16
+ </div>
@@ -0,0 +1,6 @@
1
+ <h1>Editing God</h1>
2
+
3
+ <%= render 'form', god: @god %>
4
+
5
+ <%= link_to 'Show', @god %> |
6
+ <%= link_to 'Back', gods_path %>
@@ -0,0 +1,35 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Gods</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Id</th>
9
+ <th>Name</th>
10
+ <th>Created At</th>
11
+ <th colspan="3"></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% @gods.each do |god| %>
17
+ <tr>
18
+ <td><%= god.id %></td>
19
+ <td><%= god.name %></td>
20
+ <td><%= god.created_at %></td>
21
+ <td><%= link_to 'Show', god %></td>
22
+ <td><%= link_to 'Edit', edit_god_path(god) %></td>
23
+ <td><%= link_to 'Destroy', god, method: :delete,
24
+ data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %></td>
25
+ </tr>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ <%= link_to 'New God', new_god_path %>
30
+
31
+ <br>
32
+
33
+ <h2>Force Directed Graph</h2>
34
+ <svg width="960" height="600"></svg>
35
+
@@ -0,0 +1,5 @@
1
+ <h1>New God</h1>
2
+
3
+ <%= render 'form', god: @god %>
4
+
5
+ <%= link_to 'Back', gods_path %>
@@ -0,0 +1,9 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <%= render @god %>
4
+
5
+ <%= link_to 'Edit', edit_god_path(@god) %> |
6
+ <%= link_to 'Back', gods_path %>
7
+
8
+
9
+ <p style="color: green"><%= notice %></p>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= javascript_importmap_tags %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../config/application'
5
+ require 'importmap/commands'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../config/boot'
5
+ require 'rake'
6
+ Rake.application.run
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'fileutils'
5
+
6
+ # path to your application root.
7
+ APP_ROOT = File.expand_path('..', __dir__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ FileUtils.chdir APP_ROOT do
14
+ # This script is a way to set up or update your development environment automatically.
15
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
16
+ # Add necessary setup steps to this file.
17
+
18
+ puts '== Installing dependencies =='
19
+ system! 'gem install bundler --conservative'
20
+ system('bundle check') || system!('bundle install')
21
+
22
+ # puts "\n== Copying sample files =="
23
+ # unless File.exist?("config/database.yml")
24
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
25
+ # end
26
+
27
+ puts "\n== Preparing database =="
28
+ system! 'bin/rails db:prepare'
29
+
30
+ puts "\n== Removing old logs and tempfiles =="
31
+ system! 'bin/rails log:clear tmp:clear'
32
+
33
+ puts "\n== Restarting application server =="
34
+ system! 'bin/rails restart'
35
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boot'
4
+
5
+ require 'rails/all'
6
+
7
+ # Require the gems listed in Gemfile, including any gems
8
+ # you've limited to :test, :development, or :production.
9
+ Bundler.require(*Rails.groups)
10
+ require 'acts_as_graph_diagram'
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ config.load_defaults Rails::VERSION::STRING.to_f
15
+ # Configuration for the application, engines, and railties goes here.
16
+ #
17
+ # These settings can be overridden in specific environments using the files
18
+ # in config/environments, which are processed later.
19
+ #
20
+ # config.time_zone = "Central Time (US & Canada)"
21
+ # config.eager_load_paths << Rails.root.join("extras")
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
+
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -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
@@ -0,0 +1,25 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative 'application'
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/integer/time'
4
+
5
+ Rails.application.configure do
6
+ # Settings specified here will take precedence over those in config/application.rb.
7
+
8
+ # In the development environment your application's code is reloaded any time
9
+ # it changes. This slows down response time but is perfect for development
10
+ # since you don't have to restart the web server when you make code changes.
11
+ config.cache_classes = false
12
+
13
+ # Do not eager load code on boot.
14
+ config.eager_load = false
15
+
16
+ # Show full error reports.
17
+ config.consider_all_requests_local = true
18
+
19
+ # Enable server timing
20
+ config.server_timing = true
21
+
22
+ # Enable/disable caching. By default caching is disabled.
23
+ # Run rails dev:cache to toggle caching.
24
+ if Rails.root.join('tmp/caching-dev.txt').exist?
25
+ config.action_controller.perform_caching = true
26
+ config.action_controller.enable_fragment_cache_logging = true
27
+
28
+ config.cache_store = :memory_store
29
+ config.public_file_server.headers = {
30
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
31
+ }
32
+ else
33
+ config.action_controller.perform_caching = false
34
+
35
+ config.cache_store = :null_store
36
+ end
37
+
38
+ # Store uploaded files on the local file system (see config/storage.yml for options).
39
+ config.active_storage.service = :local
40
+
41
+ # Don't care if the mailer can't send.
42
+ config.action_mailer.raise_delivery_errors = false
43
+
44
+ config.action_mailer.perform_caching = false
45
+
46
+ # Print deprecation notices to the Rails logger.
47
+ config.active_support.deprecation = :log
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
+
55
+ # Raise an error on page load if there are pending migrations.
56
+ config.active_record.migration_error = :page_load
57
+
58
+ # Highlight code that triggered database queries in logs.
59
+ config.active_record.verbose_query_logs = true
60
+
61
+ # Raises error for missing translations.
62
+ # config.i18n.raise_on_missing_translations = true
63
+
64
+ # Annotate rendered view with file names.
65
+ # config.action_view.annotate_rendered_view_with_filenames = true
66
+
67
+ # Uncomment if you wish to allow Action Cable access from any origin.
68
+ # config.action_cable.disable_request_forgery_protection = true
69
+
70
+ config.log_level = :warn
71
+ end