rails-uploader 0.5.7 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -7
  3. data/lib/generators/uploader/install/templates/20130905144515_create_assets.rb +1 -1
  4. data/lib/uploader/fileupload_glue.rb +22 -0
  5. data/lib/uploader/fileuploads.rb +2 -1
  6. data/lib/uploader/helpers/field_tag.rb +4 -8
  7. data/lib/uploader/version.rb +1 -1
  8. data/spec/dummy/Rakefile +2 -3
  9. data/spec/dummy/app/assets/config/manifest.js +1 -1
  10. data/spec/dummy/app/assets/stylesheets/application.css +7 -5
  11. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  12. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  13. data/spec/dummy/app/controllers/application_controller.rb +2 -1
  14. data/spec/dummy/app/jobs/application_job.rb +7 -0
  15. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  16. data/spec/dummy/app/models/application_record.rb +3 -0
  17. data/spec/dummy/app/models/article.rb +1 -1
  18. data/spec/dummy/app/models/asset.rb +1 -1
  19. data/spec/dummy/app/views/layouts/application.html.erb +18 -9
  20. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  21. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  22. data/spec/dummy/app/views/pwa/manifest.json.erb +22 -0
  23. data/spec/dummy/app/views/pwa/service-worker.js +26 -0
  24. data/spec/dummy/bin/rails +4 -0
  25. data/spec/dummy/bin/rake +4 -0
  26. data/spec/dummy/bin/setup +37 -0
  27. data/spec/dummy/config/application.rb +39 -47
  28. data/spec/dummy/config/boot.rb +4 -9
  29. data/spec/dummy/config/cable.yml +10 -0
  30. data/spec/dummy/config/database.yml +20 -13
  31. data/spec/dummy/config/environment.rb +4 -4
  32. data/spec/dummy/config/environments/development.rb +64 -22
  33. data/spec/dummy/config/environments/production.rb +74 -41
  34. data/spec/dummy/config/environments/test.rb +51 -20
  35. data/spec/dummy/config/initializers/assets.rb +12 -0
  36. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  37. data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  38. data/spec/dummy/config/initializers/inflections.rb +10 -9
  39. data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
  40. data/spec/dummy/config/locales/en.yml +28 -2
  41. data/spec/dummy/config/puma.rb +34 -0
  42. data/spec/dummy/config/storage.yml +34 -0
  43. data/spec/dummy/config.ru +4 -2
  44. data/spec/dummy/db/migrate/20120508093830_create_articles.rb +1 -1
  45. data/spec/dummy/db/migrate/20130905144515_create_assets.rb +34 -0
  46. data/spec/dummy/log/test.log +1677 -0
  47. data/spec/dummy/public/404.html +55 -14
  48. data/spec/dummy/public/406-unsupported-browser.html +66 -0
  49. data/spec/dummy/public/422.html +55 -14
  50. data/spec/dummy/public/500.html +54 -13
  51. data/spec/dummy/public/icon.png +0 -0
  52. data/spec/dummy/public/icon.svg +3 -0
  53. data/spec/dummy/public/uploads/picture/data/1/rails.png +0 -0
  54. data/spec/dummy/public/uploads/picture/data/1/thumb_rails.png +0 -0
  55. data/spec/dummy/storage/test.sqlite3 +0 -0
  56. data/spec/dummy/tmp/local_secret.txt +1 -0
  57. data/spec/factories/factories.rb +16 -0
  58. data/spec/fileuploads_spec.rb +30 -30
  59. data/spec/mongoid_spec.rb +5 -3
  60. data/spec/rails_helper.rb +80 -0
  61. data/spec/requests/attachments_controller_spec.rb +4 -4
  62. data/spec/spec_helper.rb +84 -45
  63. data/spec/uploader_spec.rb +5 -3
  64. metadata +88 -91
  65. data/spec/dummy/README.rdoc +0 -261
  66. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  68. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  69. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  70. data/spec/dummy/config/initializers/session_store.rb +0 -8
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  72. data/spec/dummy/script/rails +0 -6
  73. data/spec/factories/articles.rb +0 -9
  74. data/spec/factories/assets.rb +0 -11
  75. /data/spec/dummy/{public/favicon.ico → log/development.log} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12397692cb77791fc651ff6ee848e3e9a376327eb531187a0bccb14d3208f18f
4
- data.tar.gz: 013dd49aaca77295f886e66c1b8fc5e2d3ed86af4b0c027a2d645532c8e9dae4
3
+ metadata.gz: 9e4a47c930e19f75bff3e97c7db634701d5e8125a68b2228f62ef079c7d6591a
4
+ data.tar.gz: c16fbca2e5353a1f6f6c9bec4babdde638eaf05c31c484330360c378d4d7a439
5
5
  SHA512:
6
- metadata.gz: c3f7ff5f6530a221a1d91dc55fd231d6d78baa63d3b6511ec2ef5c5aff46c10b9e1ef5d4068d4d314bd422ae6919f209a54bb48c7d6eeca1186333ed9a293058
7
- data.tar.gz: f1d41d67e22055e0b6fe8cbb13fa86c9eabc4326c93b8ac53b86f03d88a9c6b62547d50813f3080280af66182708f68d5602a8bae2281856d8385e57dce4f753
6
+ metadata.gz: fe5651721228ed34179b47cd505d9edff7fb185bb500ceffaf847df627595ff7efedf974676467080abc434d6bb56a4f76d9c34d916be4cce5c6dcb24b008710
7
+ data.tar.gz: 77dade7760215667c1197d125cee29890386a8fa2d4a673348a103ad0724c9158daabef2abf613a95d9677b5c308e4b35af04d68ac46aa89de372122d55a41bc
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/superp/rails-uploader.svg?branch=master)](https://travis-ci.org/superp/rails-uploader)
1
+ [![Build Status](https://app.travis-ci.com/superp/rails-uploader.svg?branch=master)](https://app.travis-ci.com/superp/rails-uploader)
2
2
 
3
3
  # HTML5 File uploader for rails
4
4
 
@@ -21,7 +21,7 @@ mount Uploader::Engine => '/uploader'
21
21
  Migration for ActiveRecord:
22
22
 
23
23
  ```bash
24
- $ bundle exec rails g uploader:install
24
+ bundle exec rails g uploader:install
25
25
  ```
26
26
 
27
27
  ## Usage
@@ -48,14 +48,12 @@ class PictureUploader < CarrierWave::Uploader::Base
48
48
  # Choose what kind of storage to use for this uploader:
49
49
  storage :file
50
50
 
51
- EXTENSION_WHITELIST = %w[jpg jpeg gif png].freeze
52
-
53
51
  version :thumb do
54
52
  process resize_to_fill: [100, 100]
55
53
  end
56
54
 
57
55
  def extension_whitelist
58
- EXTENSION_WHITELIST
56
+ %w[jpg jpeg gif png]
59
57
  end
60
58
  end
61
59
  ```
@@ -286,6 +284,8 @@ That's it!
286
284
 
287
285
  ## Testing
288
286
 
289
- rspec ./spec/
287
+ ```
288
+ rspec ./spec/
289
+ ```
290
290
 
291
- Copyright (c) 2016 Fodojo LLC, released under the MIT license
291
+ Copyright (c) 2022 Fodojo LLC, released under the MIT license
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateAssets < ActiveRecord::Migration
3
+ class CreateAssets < ActiveRecord::Migration[6.1]
4
4
  def self.up
5
5
  create_table :assets do |t|
6
6
  t.string :data_file_name, null: false
@@ -62,6 +62,28 @@ module Uploader
62
62
  association(method_name).send(name)
63
63
  end
64
64
 
65
+ def extension_whitelist(method_name)
66
+ model = klass(method_name)
67
+ uploader = model.respond_to?(:uploaders) ? model.uploaders[:data] : nil
68
+
69
+ possible_sources = [
70
+ @record,
71
+ model,
72
+ uploader,
73
+ uploader.respond_to?(:new) ? uploader.new : nil
74
+ ].compact
75
+
76
+ possible_sources.each do |source|
77
+ if source.respond_to?(:extension_whitelist)
78
+ return source.extension_whitelist
79
+ end
80
+ end
81
+
82
+ return unless uploader.try(:const_defined?, :EXTENSION_WHITELIST)
83
+
84
+ uploader::EXTENSION_WHITELIST
85
+ end
86
+
65
87
  protected
66
88
 
67
89
  def available_fileuploads
@@ -9,7 +9,8 @@ module Uploader
9
9
  included do
10
10
  class_attribute :fileupload_options, instance_writer: false
11
11
 
12
- delegate :asset, :multiple?, :params, :klass, to: :fileupload_glue, prefix: :fileupload
12
+ delegate :asset, :multiple?, :params, :klass,
13
+ :extension_whitelist, to: :fileupload_glue, prefix: :fileupload
13
14
 
14
15
  after_create :fileupload_update, if: :fileupload_changed?
15
16
  end
@@ -73,10 +73,10 @@ module Uploader
73
73
  end
74
74
 
75
75
  def input_html
76
- @input_html ||= { multiple: multiple?, class: 'uploader' }.merge(input_html_options)
76
+ @input_html ||= { multiple: multiple?, class: 'uploader' }.merge!(input_html_options)
77
77
  @input_html[:data] ||= {}
78
78
  @input_html[:data][:url] ||= attachments_path(singular: !multiple?)
79
- @input_html[:accept] ||= extract_extension_whitelist
79
+ @input_html[:accept] ||= ".#{extension_whitelist.join(',.')}" if extension_whitelist.any?
80
80
  @input_html
81
81
  end
82
82
 
@@ -84,12 +84,8 @@ module Uploader
84
84
  @options.reject { |key, _value| RESERVED_OPTIONS_KEYS.include?(key.to_s) }
85
85
  end
86
86
 
87
- def extract_extension_whitelist
88
- return unless klass.respond_to?(:uploaders)
89
- return unless klass.uploaders[:data].try(:const_defined?, :EXTENSION_WHITELIST)
90
-
91
- exts = klass.uploaders[:data]::EXTENSION_WHITELIST
92
- ".#{exts.join(', .')}" if exts.any?
87
+ def extension_whitelist
88
+ @extension_whitelist ||= Array(@object.fileupload_extension_whitelist(method_name)).compact
93
89
  end
94
90
  end
95
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploader
4
- VERSION = '0.5.7'
4
+ VERSION = '0.5.9'
5
5
  end
data/spec/dummy/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
- #!/usr/bin/env rake
2
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
3
 
5
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative "config/application"
6
5
 
7
- Dummy::Application.load_tasks
6
+ Rails.application.load_tasks
@@ -1,3 +1,3 @@
1
1
  //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
2
  //= link_directory ../stylesheets .css
3
+ //= link testing_manifest.js
@@ -3,11 +3,13 @@
3
3
  * listed below.
4
4
  *
5
5
  * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
10
12
  *
11
- *= require_self
12
13
  *= require_tree .
13
- */
14
+ *= require_self
15
+ */
@@ -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
@@ -1,3 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
- protect_from_forgery
2
+ # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
+ allow_browser versions: :modern
3
4
  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
+ primary_abstract_class
3
+ end
@@ -1,4 +1,4 @@
1
- class Article < ActiveRecord::Base
1
+ class Article < ApplicationRecord
2
2
  has_one :picture, as: :assetable, dependent: :destroy
3
3
 
4
4
  fileuploads :picture
@@ -20,7 +20,7 @@
20
20
  # index_assets_on_assetable_type_and_assetable_id (assetable_type,assetable_id)
21
21
  # index_assets_on_user_id (user_id)
22
22
  #
23
- class Asset < ActiveRecord::Base
23
+ class Asset < ApplicationRecord
24
24
  include Uploader::Asset
25
25
 
26
26
  belongs_to :assetable, polymorphic: true
@@ -1,14 +1,23 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title><%= content_for(:title) || "Dummy" %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <%= csrf_meta_tags %>
8
+ <%= csp_meta_tag %>
10
9
 
11
- <%= yield %>
10
+ <%= yield :head %>
12
11
 
13
- </body>
12
+ <link rel="manifest" href="/manifest.json">
13
+ <link rel="icon" href="/icon.png" type="image/png">
14
+ <link rel="icon" href="/icon.svg" type="image/svg+xml">
15
+ <link rel="apple-touch-icon" href="/icon.png">
16
+ <%= stylesheet_link_tag "application" %>
17
+ <%= javascript_include_tag "application" %>
18
+ </head>
19
+
20
+ <body>
21
+ <%= yield %>
22
+ </body>
14
23
  </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,22 @@
1
+ {
2
+ "name": "Dummy",
3
+ "icons": [
4
+ {
5
+ "src": "/icon.png",
6
+ "type": "image/png",
7
+ "sizes": "512x512"
8
+ },
9
+ {
10
+ "src": "/icon.png",
11
+ "type": "image/png",
12
+ "sizes": "512x512",
13
+ "purpose": "maskable"
14
+ }
15
+ ],
16
+ "start_url": "/",
17
+ "display": "standalone",
18
+ "scope": "/",
19
+ "description": "Dummy.",
20
+ "theme_color": "red",
21
+ "background_color": "red"
22
+ }
@@ -0,0 +1,26 @@
1
+ // Add a service worker for processing Web Push notifications:
2
+ //
3
+ // self.addEventListener("push", async (event) => {
4
+ // const { title, options } = await event.data.json()
5
+ // event.waitUntil(self.registration.showNotification(title, options))
6
+ // })
7
+ //
8
+ // self.addEventListener("notificationclick", function(event) {
9
+ // event.notification.close()
10
+ // event.waitUntil(
11
+ // clients.matchAll({ type: "window" }).then((clientList) => {
12
+ // for (let i = 0; i < clientList.length; i++) {
13
+ // let client = clientList[i]
14
+ // let clientPath = (new URL(client.url)).pathname
15
+ //
16
+ // if (clientPath == event.notification.data.path && "focus" in client) {
17
+ // return client.focus()
18
+ // }
19
+ // }
20
+ //
21
+ // if (clients.openWindow) {
22
+ // return clients.openWindow(event.notification.data.path)
23
+ // }
24
+ // })
25
+ // )
26
+ // })
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+ APP_NAME = "dummy"
6
+
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.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
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"
37
+ end
@@ -1,52 +1,44 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require
6
- require 'rails-uploader'
7
- require 'carrierwave'
8
- require 'carrierwave/orm/activerecord'
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ require "active_record/railtie"
8
+ require "active_storage/engine"
9
+ require "action_controller/railtie"
10
+ require "action_mailer/railtie"
11
+ require "action_mailbox/engine"
12
+ require "action_text/engine"
13
+ require "action_view/railtie"
14
+ require "action_cable/engine"
15
+ # require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
9
20
 
10
21
  module Dummy
11
22
  class Application < Rails::Application
12
- # Settings in config/environments/* take precedence over those specified here.
13
- # Application configuration should go into files in config/initializers
14
- # -- all .rb files in that directory are automatically loaded.
15
-
16
- # Custom directories with classes and modules you want to be autoloadable.
17
- # config.autoload_paths += %W(#{config.root}/extras)
18
-
19
- # Only load the plugins named here, in the order given (default is alphabetical).
20
- # :all can be used as a placeholder for all plugins not explicitly named.
21
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
22
-
23
- # Activate observers that should always be running.
24
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
25
-
26
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
27
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
28
- # config.time_zone = 'Central Time (US & Canada)'
29
-
30
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
31
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
32
- # config.i18n.default_locale = :de
33
-
34
- # Configure the default encoding used in templates for Ruby 1.9.
35
- config.encoding = 'utf-8'
36
-
37
- # Configure sensitive parameters which will be filtered from the log file.
38
- config.filter_parameters += [:password]
39
-
40
- # Use SQL instead of Active Record's schema dumper when creating the database.
41
- # This is necessary if your schema can't be completely dumped by the schema dumper,
42
- # like if you have constraints or database-specific column types
43
- # config.active_record.schema_format = :sql
44
-
45
- # Enable the asset pipeline
46
- config.assets.enabled = true
47
-
48
- # Version of your assets, change this if you want to expire all your assets
49
- config.assets.version = '1.0'
23
+ config.load_defaults Rails::VERSION::STRING.to_f
24
+
25
+ # For compatibility with applications that use this config
26
+ config.action_controller.include_all_helpers = false
27
+
28
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
29
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
30
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
31
+ config.autoload_lib(ignore: %w[assets tasks])
32
+
33
+ # Configuration for the application, engines, and railties goes here.
34
+ #
35
+ # These settings can be overridden in specific environments using the files
36
+ # in config/environments, which are processed later.
37
+ #
38
+ # config.time_zone = "Central Time (US & Canada)"
39
+ # config.eager_load_paths << Rails.root.join("extras")
40
+
41
+ # Don't generate system test files.
42
+ config.generators.system_tests = nil
50
43
  end
51
44
  end
52
-
@@ -1,10 +1,5 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
1
+ # Set up gems listed in the Gemfile.
2
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
3
 
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
+ $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
@@ -1,25 +1,32 @@
1
- # SQLite version 3.x
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
2
  # gem install sqlite3
3
3
  #
4
4
  # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
7
8
  adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
10
  timeout: 5000
11
11
 
12
+ development:
13
+ <<: *default
14
+ database: storage/development.sqlite3
15
+
12
16
  # Warning: The database defined as "test" will be erased and
13
17
  # re-generated from your development database when you run "rake".
14
18
  # Do not set this db to the same as development or production.
15
19
  test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
+ <<: *default
21
+ database: storage/test.sqlite3
22
+
20
23
 
24
+ # SQLite3 write its data on the local filesystem, as such it requires
25
+ # persistent disks. If you are deploying to a managed service, you should
26
+ # make sure it provides disk persistence, as many don't.
27
+ #
28
+ # Similarly, if you deploy your application as a Docker container, you must
29
+ # ensure the database is located in a persisted volume.
21
30
  production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
31
+ <<: *default
32
+ # database: path/to/persistent/storage/production.sqlite3
@@ -1,5 +1,5 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
1
+ # Load the Rails application.
2
+ require_relative "application"
3
3
 
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!