cable_ready 5.0.0.pre3 → 5.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/Gemfile.lock +6 -6
  4. data/README.md +6 -2
  5. data/app/helpers/cable_ready_helper.rb +15 -2
  6. data/app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb +19 -0
  7. data/app/models/concerns/cable_ready/updatable/collections_registry.rb +33 -0
  8. data/app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb +28 -0
  9. data/app/models/concerns/cable_ready/updatable.rb +98 -0
  10. data/app/models/concerns/extend_has_many.rb +13 -0
  11. data/lib/cable_ready/channels.rb +1 -1
  12. data/lib/cable_ready/compoundable.rb +1 -1
  13. data/lib/cable_ready/version.rb +1 -1
  14. data/lib/generators/cable_ready/{stream_from_generator.rb → helpers_generator.rb} +1 -1
  15. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  16. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  17. data/test/dummy/app/controllers/application_controller.rb +2 -0
  18. data/test/dummy/app/helpers/application_helper.rb +2 -0
  19. data/test/dummy/app/jobs/application_job.rb +7 -0
  20. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  21. data/test/dummy/app/models/application_record.rb +3 -0
  22. data/test/dummy/app/models/global_idable_entity.rb +16 -0
  23. data/test/dummy/app/models/post.rb +4 -0
  24. data/test/dummy/app/models/section.rb +6 -0
  25. data/test/dummy/app/models/team.rb +6 -0
  26. data/test/dummy/app/models/topic.rb +4 -0
  27. data/test/dummy/app/models/user.rb +7 -0
  28. data/test/dummy/config/application.rb +22 -0
  29. data/test/dummy/config/boot.rb +5 -0
  30. data/test/dummy/config/environment.rb +5 -0
  31. data/test/dummy/config/environments/development.rb +76 -0
  32. data/test/dummy/config/environments/production.rb +120 -0
  33. data/test/dummy/config/environments/test.rb +59 -0
  34. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  35. data/test/dummy/config/initializers/assets.rb +12 -0
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +8 -0
  37. data/test/dummy/config/initializers/cable_ready.rb +18 -0
  38. data/test/dummy/config/initializers/content_security_policy.rb +28 -0
  39. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  41. data/test/dummy/config/initializers/inflections.rb +16 -0
  42. data/test/dummy/config/initializers/mime_types.rb +4 -0
  43. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/test/dummy/config/puma.rb +43 -0
  46. data/test/dummy/config/routes.rb +3 -0
  47. data/test/dummy/db/migrate/20210902154139_create_users.rb +9 -0
  48. data/test/dummy/db/migrate/20210902154153_create_posts.rb +10 -0
  49. data/test/dummy/db/migrate/20210904081930_create_topics.rb +9 -0
  50. data/test/dummy/db/migrate/20210904093607_create_sections.rb +9 -0
  51. data/test/dummy/db/migrate/20210913191735_create_teams.rb +8 -0
  52. data/test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb +5 -0
  53. data/test/dummy/db/schema.rb +49 -0
  54. data/test/dummy/test/models/post_test.rb +7 -0
  55. data/test/dummy/test/models/section_test.rb +7 -0
  56. data/test/dummy/test/models/team_test.rb +7 -0
  57. data/test/dummy/test/models/topic_test.rb +7 -0
  58. data/test/dummy/test/models/user_test.rb +7 -0
  59. data/test/lib/cable_ready/compoundable_test.rb +26 -0
  60. data/test/lib/cable_ready/helper_test.rb +25 -0
  61. data/test/lib/cable_ready/identifiable_test.rb +0 -6
  62. data/test/lib/cable_ready/updatable_test.rb +112 -0
  63. data/test/test_helper.rb +4 -1
  64. metadata +123 -13
  65. data/cable_ready.gemspec +0 -27
  66. data/package.json +0 -41
  67. data/yarn.lock +0 -2562
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 373a72dbd75eb888edac2ccf0d86cfd3cf2733efa69691ce6860886efdac64f9
4
- data.tar.gz: 247ea517c6fe32417a06daaefd726ed10a4f2303ca1bdd6cb7e8bd175cbcb2ca
3
+ metadata.gz: c2b77b47c0eb8de63edb60db0cb235067ffd3ca9006ad0b2ea61f0b48d187203
4
+ data.tar.gz: 324b35591eed716da4e7fefda9bf063d9dd8809d5462102936d7c5dd7221caf1
5
5
  SHA512:
6
- metadata.gz: a03bab6e32acfe5660bebcb08a4b5f782a92b1cf297fdf74627b804f435f55873991202fcf8c715a5644598f5d00af8fa9b4069fb6dcb254c4d4524d3d68820c
7
- data.tar.gz: a3ca97dfb6d81aa0d7c12e9db9722b1b2eec834cc15be0b066493ccdc1da99031557fe4c0ffd915f40ed9dd09de8d4ac8e28be4b4c3d0dc7bafbd8240b7ab862
6
+ metadata.gz: d3117dd4df1af91c451d3e22c84b96f2f430af511437145c03b1212217b87be1b0ce71e58d507ec4a10c268653f04518823ab66e02fd4153f91b3b506fcb985f
7
+ data.tar.gz: 5416faffa9ba9a6550989f1d21fb7d54adfa1f50fe5d4f96040aaff4de1c0f22dcc4c3128731ae5602dd56733429a9f9164003777ebd9a0629d88f3c9c23a187
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [v5.0.0.pre3](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre3) (2021-08-22)
4
+
5
+ [Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre2...v5.0.0.pre3)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - redirect\_to operation [\#144](https://github.com/stimulusreflex/cable_ready/pull/144) ([leastbad](https://github.com/leastbad))
10
+ - RFC simplifed JSON payload + named batches [\#142](https://github.com/stimulusreflex/cable_ready/pull/142) ([leastbad](https://github.com/leastbad))
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Bump path-parse from 1.0.6 to 1.0.7 [\#143](https://github.com/stimulusreflex/cable_ready/pull/143) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+
3
16
  ## [v5.0.0.pre2](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre2) (2021-07-21)
4
17
 
5
18
  [Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre1...v5.0.0.pre2)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cable_ready (5.0.0.pre3)
4
+ cable_ready (5.0.0.pre4)
5
5
  rails (>= 5.2)
6
6
  thread-local (>= 1.1.0)
7
7
 
@@ -138,15 +138,13 @@ GEM
138
138
  mini_mime (>= 0.1.1)
139
139
  marcel (1.0.1)
140
140
  method_source (0.9.2)
141
- mini_mime (1.1.0)
142
- mini_portile2 (2.6.1)
141
+ mini_mime (1.1.1)
143
142
  minitest (5.14.4)
144
143
  mocha (1.13.0)
145
144
  multi_json (1.15.0)
146
145
  multipart-post (2.1.1)
147
146
  nio4r (2.5.8)
148
- nokogiri (1.12.3)
149
- mini_portile2 (~> 2.6.1)
147
+ nokogiri (1.12.5-x86_64-linux)
150
148
  racc (~> 1.4)
151
149
  octokit (4.21.0)
152
150
  faraday (>= 0.9)
@@ -189,7 +187,7 @@ GEM
189
187
  rails-dom-testing (2.0.3)
190
188
  activesupport (>= 4.2.0)
191
189
  nokogiri (>= 1.6)
192
- rails-html-sanitizer (1.4.1)
190
+ rails-html-sanitizer (1.4.2)
193
191
  loofah (~> 2.3)
194
192
  railties (6.1.4.1)
195
193
  actionpack (= 6.1.4.1)
@@ -227,6 +225,7 @@ GEM
227
225
  actionpack (>= 4.0)
228
226
  activesupport (>= 4.0)
229
227
  sprockets (>= 3.0.0)
228
+ sqlite3 (1.4.2)
230
229
  standard (1.1.7)
231
230
  rubocop (= 1.18.4)
232
231
  rubocop-performance (= 1.11.4)
@@ -254,6 +253,7 @@ DEPENDENCIES
254
253
  pry
255
254
  pry-nav
256
255
  rake
256
+ sqlite3
257
257
  standardrb
258
258
 
259
259
  BUNDLED WITH
data/README.md CHANGED
@@ -2,8 +2,12 @@
2
2
  <img src="https://gitcdn.link/repo/stimulusreflex/cable_ready/master/assets/cable-ready-logo-with-copy.svg" width="360" />
3
3
  <h1 align="center">Welcome to CableReady 👋</h1>
4
4
  <p align="center">
5
- <img src="https://img.shields.io/gem/v/cable_ready.svg?color=red" />
6
- <img src="https://img.shields.io/npm/v/cable_ready.svg?color=blue" />
5
+ <a href="https://rubygems.org/gems/cable_ready">
6
+ <img src="https://img.shields.io/gem/v/cable_ready.svg?color=red" />
7
+ </a>
8
+ <a href="https://www.npmjs.com/package/cable_ready">
9
+ <img src="https://img.shields.io/npm/v/cable_ready.svg?color=blue" />
10
+ </a>
7
11
  <a href="https://www.npmjs.com/package/cable_ready">
8
12
  <img alt="downloads" src="https://img.shields.io/npm/dm/cable_ready.svg?color=blue" target="_blank" />
9
13
  </a>
@@ -4,8 +4,21 @@ module CableReadyHelper
4
4
  include CableReady::Compoundable
5
5
  include CableReady::StreamIdentifier
6
6
 
7
- def stream_from(*keys)
7
+ def stream_from(*keys, html_options: {})
8
+ tag.stream_from(**build_options(*keys, html_options))
9
+ end
10
+
11
+ def updates_for(*keys, url: nil, debounce: nil, html_options: {}, &block)
12
+ options = build_options(*keys, html_options)
13
+ options[:url] = url if url
14
+ options[:debounce] = debounce if debounce
15
+ tag.updates_for(**options) { capture(&block) }
16
+ end
17
+
18
+ private
19
+
20
+ def build_options(*keys, html_options)
8
21
  keys.select!(&:itself)
9
- tag.stream_from(identifier: signed_stream_identifier(compound(keys)))
22
+ {identifier: signed_stream_identifier(compound(keys))}.merge(html_options)
10
23
  end
11
24
  end
@@ -0,0 +1,19 @@
1
+ module CableReady
2
+ module Updatable
3
+ class CollectionUpdatableCallbacks
4
+ def initialize(operation)
5
+ @operation = operation
6
+ end
7
+
8
+ def after_commit(model)
9
+ update_collections(model)
10
+ end
11
+
12
+ private
13
+
14
+ def update_collections(model)
15
+ model.class.cable_ready_collections.broadcast_for!(model, @operation)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ module CableReady
2
+ module Updatable
3
+ class CollectionsRegistry
4
+ def initialize
5
+ @registered_collections = []
6
+ end
7
+
8
+ def register(collection)
9
+ @registered_collections << collection
10
+ end
11
+
12
+ def broadcast_for!(model, operation)
13
+ @registered_collections.select { |c| c[:options][:on].include?(operation) }
14
+ .each do |collection|
15
+ resource = find_resource_for_update(collection, model)
16
+ next if resource.nil?
17
+
18
+ collection[:klass].cable_ready_update_collection(resource, collection[:name]) if collection[:options][:if].call(resource)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def find_resource_for_update(collection, model)
25
+ raise ArgumentError, "Could not find inverse_of for #{collection[:name]}" unless collection[:inverse_association]
26
+
27
+ resource = model
28
+ resource = resource.send(collection[:through_association].underscore) if collection[:through_association]
29
+ resource.send(collection[:inverse_association].underscore)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module CableReady
2
+ module Updatable
3
+ class ModelUpdatableCallbacks
4
+ def initialize(operation, enabled_operations = %i[create update destroy])
5
+ @operation = operation
6
+ @enabled_operations = enabled_operations
7
+ end
8
+
9
+ def after_commit(model)
10
+ return unless @enabled_operations.include?(@operation)
11
+
12
+ send("broadcast_#{@operation}", model)
13
+ end
14
+
15
+ private
16
+
17
+ def broadcast_create(model)
18
+ ActionCable.server.broadcast(model.class, {})
19
+ end
20
+ alias_method :broadcast_destroy, :broadcast_create
21
+
22
+ def broadcast_update(model)
23
+ ActionCable.server.broadcast(model.class, {})
24
+ ActionCable.server.broadcast(model.to_global_id, {})
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CableReady
4
+ module Updatable
5
+ extend ::ActiveSupport::Concern
6
+
7
+ included do |base|
8
+ if base < ActiveRecord::Base
9
+ include ExtendHasMany
10
+
11
+ after_commit CollectionUpdatableCallbacks.new(:create), on: :create
12
+ after_commit CollectionUpdatableCallbacks.new(:update), on: :update
13
+ after_commit CollectionUpdatableCallbacks.new(:destroy), on: :destroy
14
+
15
+ def self.enable_updates(*options)
16
+ options = options.extract_options!
17
+ options = {
18
+ on: [:create, :update, :destroy],
19
+ if: -> { true }
20
+ }.merge(options)
21
+
22
+ enabled_operations = Array(options[:on])
23
+
24
+ after_commit(ModelUpdatableCallbacks.new(:create, enabled_operations), {on: :create, if: options[:if]})
25
+ after_commit(ModelUpdatableCallbacks.new(:update, enabled_operations), {on: :update, if: options[:if]})
26
+ after_commit(ModelUpdatableCallbacks.new(:destroy, enabled_operations), {on: :destroy, if: options[:if]})
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ module ClassMethods
34
+ def has_many(name, scope = nil, **options, &extension)
35
+ option = options.delete(:enable_updates)
36
+ broadcast = option.present?
37
+ result = super
38
+ enrich_association_with_updates(name, option) if broadcast
39
+ result
40
+ end
41
+
42
+ def cable_ready_collections
43
+ @cable_ready_collections ||= CollectionsRegistry.new
44
+ end
45
+
46
+ def cable_ready_update_collection(resource, name)
47
+ identifier = resource.to_global_id.to_s + ":" + name.to_s
48
+ ActionCable.server.broadcast(identifier, {})
49
+ end
50
+
51
+ def enrich_association_with_updates(name, option)
52
+ reflection = reflect_on_association(name)
53
+
54
+ inverse_of = reflection.inverse_of&.name&.to_s
55
+ through_association = nil
56
+
57
+ if reflection.through_reflection?
58
+ inverse_of = reflection.through_reflection.inverse_of&.name&.to_s
59
+ through_association = reflection.through_reflection.name.to_s.singularize
60
+ end
61
+
62
+ options = {
63
+ on: [:create, :update, :destroy],
64
+ if: ->(resource) { true }
65
+ }
66
+
67
+ case option
68
+ when TrueClass
69
+ # proceed!
70
+ when FalseClass
71
+ options[:on] = []
72
+ when Array
73
+ options[:on] = option
74
+ when Symbol
75
+ options[:on] = [option]
76
+ when Hash
77
+ option[:on] = Array(option[:on]) if option[:on]
78
+ options = options.merge!(option)
79
+ when Proc
80
+ options[:if] = option
81
+ else
82
+ raise ArgumentError, "Invalid enable_updates option #{option}"
83
+ end
84
+
85
+ reflection.klass.send(:include, CableReady::Updatable) unless reflection.klass.respond_to?(:cable_ready_collections)
86
+
87
+ reflection.klass.cable_ready_collections.register({
88
+ klass: self,
89
+ foreign_key: reflection.foreign_key,
90
+ name: name,
91
+ inverse_association: inverse_of,
92
+ through_association: through_association,
93
+ options: options
94
+ })
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExtendHasMany
4
+ extend ::ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def has_many(*args, &block)
8
+ options = args.extract_options!
9
+ options[:extend] = Array(options[:extend]).push(ClassMethods)
10
+ super(*args, **options, &block)
11
+ end
12
+ end
13
+ end
@@ -13,7 +13,7 @@ module CableReady
13
13
 
14
14
  def [](*keys)
15
15
  keys.select!(&:itself)
16
- identifier = keys.many? || (keys.one? && keys.first.is_a?(ActiveRecord::Base)) ? compound(keys) : keys.pop
16
+ identifier = keys.many? || (keys.one? && keys.first.respond_to?(:to_global_id)) ? compound(keys) : keys.pop
17
17
  @channels[identifier] ||= CableReady::Channel.new(identifier)
18
18
  end
19
19
 
@@ -4,7 +4,7 @@ module CableReady
4
4
  module Compoundable
5
5
  def compound(keys)
6
6
  keys.map { |key|
7
- key.class < ActiveRecord::Base ? key.to_global_id.to_s : key.to_s
7
+ key.respond_to?(:to_global_id) ? key.to_global_id.to_s : key.to_s
8
8
  }.join(":")
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CableReady
4
- VERSION = "5.0.0.pre3"
4
+ VERSION = "5.0.0.pre4"
5
5
  end
@@ -4,7 +4,7 @@ require "rails/generators"
4
4
  require "fileutils"
5
5
 
6
6
  module CableReady
7
- class StreamFromGenerator < Rails::Generators::Base
7
+ class HelpersGenerator < Rails::Generators::Base
8
8
  desc "Initializes CableReady with a reference to the shared ActionCable consumer"
9
9
  source_root File.expand_path("templates", __dir__)
10
10
 
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,16 @@
1
+ class GlobalIdableEntity
2
+ include GlobalID::Identification
3
+ include CableReady::Updatable
4
+
5
+ def id
6
+ "fake-id"
7
+ end
8
+
9
+ def self.find(id)
10
+ new if id == "fake-id"
11
+ end
12
+
13
+ def fake_update
14
+ ModelUpdatableCallbacks.new(:update).after_commit(self)
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ class Post < ApplicationRecord
2
+ include CableReady::Updatable
3
+ belongs_to :user
4
+ end
@@ -0,0 +1,6 @@
1
+ class Section < ApplicationRecord
2
+ include CableReady::Updatable
3
+ enable_updates if: -> { updates_enabled }
4
+
5
+ attribute :updates_enabled, :boolean, default: false
6
+ end
@@ -0,0 +1,6 @@
1
+ class Team < ApplicationRecord
2
+ include CableReady::Updatable
3
+ enable_updates
4
+
5
+ has_many :users, enable_updates: true
6
+ end
@@ -0,0 +1,4 @@
1
+ class Topic < ApplicationRecord
2
+ include CableReady::Updatable
3
+ enable_updates on: :create
4
+ end
@@ -0,0 +1,7 @@
1
+ class User < ApplicationRecord
2
+ include CableReady::Updatable
3
+ enable_updates
4
+
5
+ has_many :posts, enable_updates: true
6
+ belongs_to :team, optional: true, touch: true
7
+ end
@@ -0,0 +1,22 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+ require "cable_ready"
9
+
10
+ module Dummy
11
+ class Application < Rails::Application
12
+ config.load_defaults Rails::VERSION::STRING.to_f
13
+
14
+ # Configuration for the application, engines, and railties goes here.
15
+ #
16
+ # These settings can be overridden in specific environments using the files
17
+ # in config/environments, which are processed later.
18
+ #
19
+ # config.time_zone = "Central Time (US & Canada)"
20
+ # config.eager_load_paths << Rails.root.join("extras")
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,76 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
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
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable/disable caching. By default caching is disabled.
18
+ # Run rails dev:cache to toggle caching.
19
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
20
+ config.action_controller.perform_caching = true
21
+ config.action_controller.enable_fragment_cache_logging = true
22
+
23
+ config.cache_store = :memory_store
24
+ config.public_file_server.headers = {
25
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
26
+ }
27
+ else
28
+ config.action_controller.perform_caching = false
29
+
30
+ config.cache_store = :null_store
31
+ end
32
+
33
+ # Store uploaded files on the local file system (see config/storage.yml for options).
34
+ config.active_storage.service = :local
35
+
36
+ # Don't care if the mailer can't send.
37
+ config.action_mailer.raise_delivery_errors = false
38
+
39
+ config.action_mailer.perform_caching = false
40
+
41
+ # Print deprecation notices to the Rails logger.
42
+ config.active_support.deprecation = :log
43
+
44
+ # Raise exceptions for disallowed deprecations.
45
+ config.active_support.disallowed_deprecation = :raise
46
+
47
+ # Tell Active Support which deprecation messages to disallow.
48
+ config.active_support.disallowed_deprecation_warnings = []
49
+
50
+ # Raise an error on page load if there are pending migrations.
51
+ config.active_record.migration_error = :page_load
52
+
53
+ # Highlight code that triggered database queries in logs.
54
+ config.active_record.verbose_query_logs = true
55
+
56
+ # Debug mode disables concatenation and preprocessing of assets.
57
+ # This option may cause significant delays in view rendering with a large
58
+ # number of complex assets.
59
+ config.assets.debug = true
60
+
61
+ # Suppress logger output for asset requests.
62
+ config.assets.quiet = true
63
+
64
+ # Raises error for missing translations.
65
+ # config.i18n.raise_on_missing_translations = true
66
+
67
+ # Annotate rendered view with file names.
68
+ # config.action_view.annotate_rendered_view_with_filenames = true
69
+
70
+ # Use an evented file watcher to asynchronously detect changes in source code,
71
+ # routes, locales, etc. This feature depends on the listen gem.
72
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
73
+
74
+ # Uncomment if you wish to allow Action Cable access from any origin.
75
+ # config.action_cable.disable_request_forgery_protection = true
76
+ end