Update Rails demo app to Rails 5.2
Used `rails app:update` to generate/update the files
Tyler Rick
5 years ago
0 | 0 | source 'https://rubygems.org' |
1 | 1 | |
2 | 2 | gem 'dotenv-rails', groups: [:development, :test] |
3 | gem 'rails', '~> 4.2' | |
3 | gem 'rails', '~> 5.2' | |
4 | 4 | gem 'sqlite3' |
5 | 5 | gem 'recaptcha', require: 'recaptcha/rails', path: '../..' |
6 | ||
7 | group :development do | |
8 | gem 'listen' | |
9 | gem 'byebug' | |
10 | end |
0 | class CaptchaController < ApplicationController | |
1 | def index | |
2 | end | |
3 | ||
4 | def create | |
5 | if verify_recaptcha | |
6 | render text: 'YES' | |
7 | else | |
8 | render text: 'NO' | |
9 | end | |
10 | end | |
11 | end |
0 | class CaptchasController < ApplicationController | |
1 | def index | |
2 | end | |
3 | ||
4 | def create | |
5 | if verify_recaptcha | |
6 | render plain: 'YES' | |
7 | else | |
8 | render plain: 'NO' | |
9 | end | |
10 | end | |
11 | end |
0 | <% if params[:multi] %> | |
1 | <script type="text/javascript"> | |
2 | var verifyCallback = function(response) { | |
3 | alert(response); | |
4 | }; | |
5 | var widgetId1; | |
6 | var widgetId2; | |
7 | var onloadCallback = function() { | |
8 | // Renders the HTML element with id 'example1' as a reCAPTCHA widget. | |
9 | // The id of the reCAPTCHA widget is assigned to 'widgetId1'. | |
10 | widgetId1 = grecaptcha.render('example1', { | |
11 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>", | |
12 | 'theme' : 'light' | |
13 | }); | |
14 | widgetId2 = grecaptcha.render(document.getElementById('example2'), { | |
15 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>" | |
16 | }); | |
17 | grecaptcha.render('example3', { | |
18 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>", | |
19 | 'callback' : verifyCallback, | |
20 | 'theme' : 'dark' | |
21 | }); | |
22 | }; | |
23 | </script> | |
24 | ||
25 | <%= form_tag "/captchas" do |f| %> | |
26 | <div id="example1"></div> | |
27 | <%= submit_tag %> | |
28 | <% end %> | |
29 | <%= form_tag "/captchas" do %> | |
30 | <div id="example2"></div> | |
31 | <%= submit_tag %> | |
32 | <% end %> | |
33 | <%= form_tag "/captchas" do %> | |
34 | <div id="example3"></div> | |
35 | <%= submit_tag %> | |
36 | <% end %> | |
37 | <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script> | |
38 | <% elsif params[:invisible] %> | |
39 | <%= form_tag "/captchas", id: "invisible-recaptcha-form" do %> | |
40 | <%= invisible_recaptcha_tags text: 'Save changes' %> | |
41 | <% end %> | |
42 | <% else %> | |
43 | <%= form_tag "/captchas" do %> | |
44 | <%= recaptcha_tags %> | |
45 | <%= submit_tag %> | |
46 | <% end %> | |
47 | <% end %> | |
48 | <%= link_to 'Single ?', '?' if params[:multi] or params[:invisible] %> | |
49 | <%= link_to 'Multi ?', '?multi=1' unless params[:multi] %> | |
50 | <%= link_to 'Invisible ?', '?invisible=1' unless params[:invisible] %> |
0 | <% if params[:multi] %> | |
1 | <script type="text/javascript"> | |
2 | var verifyCallback = function(response) { | |
3 | alert(response); | |
4 | }; | |
5 | var widgetId1; | |
6 | var widgetId2; | |
7 | var onloadCallback = function() { | |
8 | // Renders the HTML element with id 'example1' as a reCAPTCHA widget. | |
9 | // The id of the reCAPTCHA widget is assigned to 'widgetId1'. | |
10 | widgetId1 = grecaptcha.render('example1', { | |
11 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>", | |
12 | 'theme' : 'light' | |
13 | }); | |
14 | widgetId2 = grecaptcha.render(document.getElementById('example2'), { | |
15 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>" | |
16 | }); | |
17 | grecaptcha.render('example3', { | |
18 | 'sitekey' : "<%= Recaptcha.configuration.site_key %>", | |
19 | 'callback' : verifyCallback, | |
20 | 'theme' : 'dark' | |
21 | }); | |
22 | }; | |
23 | </script> | |
24 | ||
25 | <%= form_tag "/captchas" do |f| %> | |
26 | <div id="example1"></div> | |
27 | <%= submit_tag %> | |
28 | <% end %> | |
29 | <%= form_tag "/captchas" do %> | |
30 | <div id="example2"></div> | |
31 | <%= submit_tag %> | |
32 | <% end %> | |
33 | <%= form_tag "/captchas" do %> | |
34 | <div id="example3"></div> | |
35 | <%= submit_tag %> | |
36 | <% end %> | |
37 | <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script> | |
38 | <% elsif params[:invisible] %> | |
39 | <%= form_tag "/captchas", id: "invisible-recaptcha-form" do %> | |
40 | <%= invisible_recaptcha_tags text: 'Save changes' %> | |
41 | <% end %> | |
42 | <% else %> | |
43 | <%= form_tag "/captchas" do %> | |
44 | <%= recaptcha_tags %> | |
45 | <%= submit_tag %> | |
46 | <% end %> | |
47 | <% end %> | |
48 | <%= link_to 'Single ?', '?' if params[:multi] or params[:invisible] %> | |
49 | <%= link_to 'Multi ?', '?multi=1' unless params[:multi] %> | |
50 | <%= link_to 'Invisible ?', '?invisible=1' unless params[:invisible] %> |
0 | 0 | #!/usr/bin/env ruby |
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | |
2 | 2 | load Gem.bin_path('bundler', 'bundle') |
0 | 0 | #!/usr/bin/env ruby |
1 | begin | |
2 | load File.expand_path('../spring', __FILE__) | |
3 | rescue LoadError => e | |
4 | raise unless e.message.include?('spring') | |
5 | end | |
6 | APP_PATH = File.expand_path('../../config/application', __FILE__) | |
1 | APP_PATH = File.expand_path('../config/application', __dir__) | |
7 | 2 | require_relative '../config/boot' |
8 | 3 | require 'rails/commands' |
0 | 0 | #!/usr/bin/env ruby |
1 | begin | |
2 | load File.expand_path('../spring', __FILE__) | |
3 | rescue LoadError => e | |
4 | raise unless e.message.include?('spring') | |
5 | end | |
6 | 1 | require_relative '../config/boot' |
7 | 2 | require 'rake' |
8 | 3 | Rake.application.run |
0 | 0 | #!/usr/bin/env ruby |
1 | require 'pathname' | |
1 | require 'fileutils' | |
2 | include FileUtils | |
2 | 3 | |
3 | 4 | # path to your application root. |
4 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
5 | APP_ROOT = File.expand_path('..', __dir__) | |
5 | 6 | |
6 | Dir.chdir APP_ROOT do | |
7 | def system!(*args) | |
8 | system(*args) || abort("\n== Command #{args} failed ==") | |
9 | end | |
10 | ||
11 | chdir APP_ROOT do | |
7 | 12 | # This script is a starting point to setup your application. |
8 | # Add necessary setup steps to this file: | |
13 | # Add necessary setup steps to this file. | |
9 | 14 | |
10 | puts "== Installing dependencies ==" | |
11 | system "gem install bundler --conservative" | |
12 | system "bundle check || bundle install" | |
15 | puts '== Installing dependencies ==' | |
16 | system! 'gem install bundler --conservative' | |
17 | system('bundle check') || system!('bundle install') | |
18 | ||
19 | # Install JavaScript dependencies if using Yarn | |
20 | # system('bin/yarn') | |
13 | 21 | |
14 | 22 | # puts "\n== Copying sample files ==" |
15 | # unless File.exist?("config/database.yml") | |
16 | # system "cp config/database.yml.sample config/database.yml" | |
23 | # unless File.exist?('config/database.yml') | |
24 | # cp 'config/database.yml.sample', 'config/database.yml' | |
17 | 25 | # end |
18 | 26 | |
19 | 27 | puts "\n== Preparing database ==" |
20 | system "bin/rake db:setup" | |
28 | system! 'bin/rails db:setup' | |
21 | 29 | |
22 | 30 | puts "\n== Removing old logs and tempfiles ==" |
23 | system "rm -f log/*" | |
24 | system "rm -rf tmp/cache" | |
31 | system! 'bin/rails log:clear tmp:clear' | |
25 | 32 | |
26 | 33 | puts "\n== Restarting application server ==" |
27 | system "touch tmp/restart.txt" | |
34 | system! 'bin/rails restart' | |
28 | 35 | end |
0 | #!/usr/bin/env ruby | |
1 | require 'fileutils' | |
2 | include FileUtils | |
3 | ||
4 | # path to your application root. | |
5 | APP_ROOT = File.expand_path('..', __dir__) | |
6 | ||
7 | def system!(*args) | |
8 | system(*args) || abort("\n== Command #{args} failed ==") | |
9 | end | |
10 | ||
11 | chdir APP_ROOT do | |
12 | # This script is a way to update your development environment automatically. | |
13 | # Add necessary update steps to this file. | |
14 | ||
15 | puts '== Installing dependencies ==' | |
16 | system! 'gem install bundler --conservative' | |
17 | system('bundle check') || system!('bundle install') | |
18 | ||
19 | # Install JavaScript dependencies if using Yarn | |
20 | # system('bin/yarn') | |
21 | ||
22 | puts "\n== Updating database ==" | |
23 | system! 'bin/rails db:migrate' | |
24 | ||
25 | puts "\n== Removing old logs and tempfiles ==" | |
26 | system! 'bin/rails log:clear tmp:clear' | |
27 | ||
28 | puts "\n== Restarting application server ==" | |
29 | system! 'bin/rails restart' | |
30 | end |
0 | #!/usr/bin/env ruby | |
1 | APP_ROOT = File.expand_path('..', __dir__) | |
2 | Dir.chdir(APP_ROOT) do | |
3 | begin | |
4 | exec "yarnpkg", *ARGV | |
5 | rescue Errno::ENOENT | |
6 | $stderr.puts "Yarn executable was not detected in the system." | |
7 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" | |
8 | exit 1 | |
9 | end | |
10 | end |
0 | require File.expand_path('../boot', __FILE__) | |
0 | require_relative 'boot' | |
1 | 1 | |
2 | 2 | require 'rails/all' |
3 | 3 | |
7 | 7 | |
8 | 8 | module Foo |
9 | 9 | class Application < Rails::Application |
10 | # Initialize configuration defaults for originally generated Rails version. | |
11 | config.load_defaults 5.0 | |
12 | ||
10 | 13 | # 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. | |
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)' | |
17 | ||
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 | ||
22 | # Do not swallow errors in after_commit/after_rollback callbacks. | |
23 | config.active_record.raise_in_transactional_callbacks = true | |
14 | # Application configuration can go into files in config/initializers | |
15 | # -- all .rb files in that directory are automatically loaded after loading | |
16 | # the framework and any gems in your application. | |
24 | 17 | end |
25 | 18 | end |
0 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
0 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | |
1 | 1 | |
2 | 2 | require 'bundler/setup' # Set up gems listed in the Gemfile. |
0 | development: | |
1 | adapter: async | |
2 | ||
3 | test: | |
4 | adapter: async | |
5 | ||
6 | production: | |
7 | adapter: redis | |
8 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> | |
9 | channel_prefix: foo_production |
0 | 0 | # Load the Rails application. |
1 | require File.expand_path('../application', __FILE__) | |
1 | require_relative 'application' | |
2 | 2 | |
3 | 3 | # Initialize the Rails application. |
4 | 4 | Rails.application.initialize! |
8 | 8 | # Do not eager load code on boot. |
9 | 9 | config.eager_load = false |
10 | 10 | |
11 | # Show full error reports and disable caching. | |
12 | config.consider_all_requests_local = true | |
13 | config.action_controller.perform_caching = false | |
11 | # Show full error reports. | |
12 | config.consider_all_requests_local = true | |
13 | ||
14 | # Enable/disable caching. By default caching is disabled. | |
15 | # Run rails dev:cache to toggle caching. | |
16 | if Rails.root.join('tmp', 'caching-dev.txt').exist? | |
17 | config.action_controller.perform_caching = true | |
18 | ||
19 | config.cache_store = :memory_store | |
20 | config.public_file_server.headers = { | |
21 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" | |
22 | } | |
23 | else | |
24 | config.action_controller.perform_caching = false | |
25 | ||
26 | config.cache_store = :null_store | |
27 | end | |
28 | ||
29 | # Store uploaded files on the local file system (see config/storage.yml for options) | |
30 | config.active_storage.service = :local | |
14 | 31 | |
15 | 32 | # Don't care if the mailer can't send. |
16 | 33 | config.action_mailer.raise_delivery_errors = false |
34 | ||
35 | config.action_mailer.perform_caching = false | |
17 | 36 | |
18 | 37 | # Print deprecation notices to the Rails logger. |
19 | 38 | config.active_support.deprecation = :log |
21 | 40 | # Raise an error on page load if there are pending migrations. |
22 | 41 | config.active_record.migration_error = :page_load |
23 | 42 | |
43 | # Highlight code that triggered database queries in logs. | |
44 | config.active_record.verbose_query_logs = true | |
45 | ||
24 | 46 | # Debug mode disables concatenation and preprocessing of assets. |
25 | 47 | # This option may cause significant delays in view rendering with a large |
26 | 48 | # number of complex assets. |
27 | 49 | config.assets.debug = true |
28 | 50 | |
29 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, | |
30 | # yet still be able to expire them through the digest params. | |
31 | config.assets.digest = true | |
32 | ||
33 | # Adds additional error checking when serving assets at runtime. | |
34 | # Checks for improperly declared sprockets dependencies. | |
35 | # Raises helpful error messages. | |
36 | config.assets.raise_runtime_errors = true | |
51 | # Suppress logger output for asset requests. | |
52 | config.assets.quiet = true | |
37 | 53 | |
38 | 54 | # Raises error for missing translations |
39 | 55 | # config.action_view.raise_on_missing_translations = true |
56 | ||
57 | # Use an evented file watcher to asynchronously detect changes in source code, | |
58 | # routes, locales, etc. This feature depends on the listen gem. | |
59 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker | |
40 | 60 | end |
0 | Rails.application.configure do | |
1 | # Settings specified here will take precedence over those in config/application.rb. | |
2 | ||
3 | # Code is not reloaded between requests. | |
4 | config.cache_classes = true | |
5 | ||
6 | # Eager load code on boot. This eager loads most of Rails and | |
7 | # your application in memory, allowing both threaded web servers | |
8 | # and those relying on copy on write to perform better. | |
9 | # Rake tasks automatically ignore this option for performance. | |
10 | config.eager_load = true | |
11 | ||
12 | # Full error reports are disabled and caching is turned on. | |
13 | config.consider_all_requests_local = false | |
14 | config.action_controller.perform_caching = true | |
15 | ||
16 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] | |
17 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). | |
18 | # config.require_master_key = true | |
19 | ||
20 | # Disable serving static files from the `/public` folder by default since | |
21 | # Apache or NGINX already handles this. | |
22 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? | |
23 | ||
24 | # Compress JavaScripts and CSS. | |
25 | config.assets.js_compressor = :uglifier | |
26 | # config.assets.css_compressor = :sass | |
27 | ||
28 | # Do not fallback to assets pipeline if a precompiled asset is missed. | |
29 | config.assets.compile = false | |
30 | ||
31 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb | |
32 | ||
33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. | |
34 | # config.action_controller.asset_host = 'http://assets.example.com' | |
35 | ||
36 | # Specifies the header that your server uses for sending files. | |
37 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache | |
38 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX | |
39 | ||
40 | # Store uploaded files on the local file system (see config/storage.yml for options) | |
41 | config.active_storage.service = :local | |
42 | ||
43 | # Mount Action Cable outside main process or domain | |
44 | # config.action_cable.mount_path = nil | |
45 | # config.action_cable.url = 'wss://example.com/cable' | |
46 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] | |
47 | ||
48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. | |
49 | # config.force_ssl = true | |
50 | ||
51 | # Use the lowest log level to ensure availability of diagnostic information | |
52 | # when problems arise. | |
53 | config.log_level = :debug | |
54 | ||
55 | # Prepend all log lines with the following tags. | |
56 | config.log_tags = [ :request_id ] | |
57 | ||
58 | # Use a different cache store in production. | |
59 | # config.cache_store = :mem_cache_store | |
60 | ||
61 | # Use a real queuing backend for Active Job (and separate queues per environment) | |
62 | # config.active_job.queue_adapter = :resque | |
63 | # config.active_job.queue_name_prefix = "foo_#{Rails.env}" | |
64 | ||
65 | config.action_mailer.perform_caching = false | |
66 | ||
67 | # Ignore bad email addresses and do not raise email delivery errors. | |
68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. | |
69 | # config.action_mailer.raise_delivery_errors = false | |
70 | ||
71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to | |
72 | # the I18n.default_locale when a translation cannot be found). | |
73 | config.i18n.fallbacks = true | |
74 | ||
75 | # Send deprecation notices to registered listeners. | |
76 | config.active_support.deprecation = :notify | |
77 | ||
78 | # Use default logging formatter so that PID and timestamp are not suppressed. | |
79 | config.log_formatter = ::Logger::Formatter.new | |
80 | ||
81 | # Use a different logger for distributed setups. | |
82 | # require 'syslog/logger' | |
83 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') | |
84 | ||
85 | if ENV["RAILS_LOG_TO_STDOUT"].present? | |
86 | logger = ActiveSupport::Logger.new(STDOUT) | |
87 | logger.formatter = config.log_formatter | |
88 | config.logger = ActiveSupport::TaggedLogging.new(logger) | |
89 | end | |
90 | ||
91 | # Do not dump schema after migrations. | |
92 | config.active_record.dump_schema_after_migration = false | |
93 | end |
0 | Rails.application.configure do | |
1 | # Settings specified here will take precedence over those in config/application.rb. | |
2 | ||
3 | # The test environment is used exclusively to run your application's | |
4 | # test suite. You never need to work with it otherwise. Remember that | |
5 | # your test database is "scratch space" for the test suite and is wiped | |
6 | # and recreated between test runs. Don't rely on the data there! | |
7 | config.cache_classes = true | |
8 | ||
9 | # Do not eager load code on boot. This avoids loading your whole application | |
10 | # just for the purpose of running a single test. If you are using a tool that | |
11 | # preloads Rails for running tests, you may have to set it to true. | |
12 | config.eager_load = false | |
13 | ||
14 | # Configure public file server for tests with Cache-Control for performance. | |
15 | config.public_file_server.enabled = true | |
16 | config.public_file_server.headers = { | |
17 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" | |
18 | } | |
19 | ||
20 | # Show full error reports and disable caching. | |
21 | config.consider_all_requests_local = true | |
22 | config.action_controller.perform_caching = false | |
23 | ||
24 | # Raise exceptions instead of rendering exception templates. | |
25 | config.action_dispatch.show_exceptions = false | |
26 | ||
27 | # Disable request forgery protection in test environment. | |
28 | config.action_controller.allow_forgery_protection = false | |
29 | ||
30 | # Store uploaded files on the local file system in a temporary directory | |
31 | config.active_storage.service = :test | |
32 | ||
33 | config.action_mailer.perform_caching = false | |
34 | ||
35 | # Tell Action Mailer not to deliver emails to the real world. | |
36 | # The :test delivery method accumulates sent emails in the | |
37 | # ActionMailer::Base.deliveries array. | |
38 | config.action_mailer.delivery_method = :test | |
39 | ||
40 | # Print deprecation notices to the stderr. | |
41 | config.active_support.deprecation = :stderr | |
42 | ||
43 | # Raises error for missing translations | |
44 | # config.action_view.raise_on_missing_translations = true | |
45 | end |
0 | # Be sure to restart your server when you modify this file. | |
1 | ||
2 | # ActiveSupport::Reloader.to_prepare do | |
3 | # ApplicationController.renderer.defaults.merge!( | |
4 | # http_host: 'example.org', | |
5 | # https: false | |
6 | # ) | |
7 | # end |
2 | 2 | # Version of your assets, change this if you want to expire all your assets. |
3 | 3 | Rails.application.config.assets.version = '1.0' |
4 | 4 | |
5 | # Add additional assets to the asset load path | |
5 | # Add additional assets to the asset load path. | |
6 | 6 | # Rails.application.config.assets.paths << Emoji.images_path |
7 | # Add Yarn node_modules folder to the asset load path. | |
8 | Rails.application.config.assets.paths << Rails.root.join('node_modules') | |
7 | 9 | |
8 | 10 | # Precompile additional assets. |
9 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. | |
10 | # Rails.application.config.assets.precompile += %w( search.js ) | |
11 | # application.js, application.css, and all non-JS/CSS in the app/assets | |
12 | # folder are already added. | |
13 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) |
0 | # Be sure to restart your server when you modify this file. | |
1 | ||
2 | # Define an application-wide content security policy | |
3 | # For further information see the following documentation | |
4 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy | |
5 | ||
6 | # Rails.application.config.content_security_policy do |policy| | |
7 | # policy.default_src :self, :https | |
8 | # policy.font_src :self, :https, :data | |
9 | # policy.img_src :self, :https, :data | |
10 | # policy.object_src :none | |
11 | # policy.script_src :self, :https | |
12 | # policy.style_src :self, :https | |
13 | ||
14 | # # Specify URI for violation reports | |
15 | # # policy.report_uri "/csp-violation-report-endpoint" | |
16 | # end | |
17 | ||
18 | # If you are using UJS then enable automatic nonce generation | |
19 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } | |
20 | ||
21 | # Report CSP violations to a specified URI | |
22 | # For further information see the following documentation: | |
23 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only | |
24 | # Rails.application.config.content_security_policy_report_only = true |
0 | 0 | # Be sure to restart your server when you modify this file. |
1 | 1 | |
2 | # Specify a serializer for the signed and encrypted cookie jars. | |
3 | # Valid options are :json, :marshal, and :hybrid. | |
2 | 4 | Rails.application.config.action_dispatch.cookies_serializer = :json |
0 | # Be sure to restart your server when you modify this file. | |
1 | # | |
2 | # This file contains migration options to ease your Rails 5.2 upgrade. | |
3 | # | |
4 | # Once upgraded flip defaults one by one to migrate to the new default. | |
5 | # | |
6 | # Read the Guide for Upgrading Ruby on Rails for more info on each option. | |
7 | ||
8 | # Make Active Record use stable #cache_key alongside new #cache_version method. | |
9 | # This is needed for recyclable cache keys. | |
10 | # Rails.application.config.active_record.cache_versioning = true | |
11 | ||
12 | # Use AES-256-GCM authenticated encryption for encrypted cookies. | |
13 | # Also, embed cookie expiry in signed or encrypted cookies for increased security. | |
14 | # | |
15 | # This option is not backwards compatible with earlier Rails versions. | |
16 | # It's best enabled when your entire app is migrated and stable on 5.2. | |
17 | # | |
18 | # Existing cookies will be converted on read then written with the new scheme. | |
19 | # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true | |
20 | ||
21 | # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages | |
22 | # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. | |
23 | # Rails.application.config.active_support.use_authenticated_message_encryption = true | |
24 | ||
25 | # Add default protection from forgery to ActionController::Base instead of in | |
26 | # ApplicationController. | |
27 | # Rails.application.config.action_controller.default_protect_from_forgery = true | |
28 | ||
29 | # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and | |
30 | # 'f' after migrating old data. | |
31 | # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true | |
32 | ||
33 | # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. | |
34 | # Rails.application.config.active_support.use_sha1_digests = true | |
35 | ||
36 | # Make `form_with` generate id attributes for any generated HTML tags. | |
37 | # Rails.application.config.action_view.form_with_generates_ids = true |
4 | 4 | |
5 | 5 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. |
6 | 6 | ActiveSupport.on_load(:action_controller) do |
7 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) | |
7 | wrap_parameters format: [:json] | |
8 | 8 | end |
9 | 9 | |
10 | 10 | # To enable root element in JSON for ActiveRecord objects. |
11 | 11 | # ActiveSupport.on_load(:active_record) do |
12 | # self.include_root_in_json = true | |
12 | # self.include_root_in_json = true | |
13 | 13 | # end |
15 | 15 | # |
16 | 16 | # This would use the information in config/locales/es.yml. |
17 | 17 | # |
18 | # The following keys must be escaped otherwise they will not be retrieved by | |
19 | # the default I18n backend: | |
20 | # | |
21 | # true, false, on, off, yes, no | |
22 | # | |
23 | # Instead, surround them with single quotes. | |
24 | # | |
25 | # en: | |
26 | # 'true': 'foo' | |
27 | # | |
18 | 28 | # To learn more, please read the Rails Internationalization guide |
19 | 29 | # available at http://guides.rubyonrails.org/i18n.html. |
20 | 30 |
0 | 0 | Rails.application.routes.draw do |
1 | root to: "captcha#index" | |
2 | post "/captchas" => "captcha#create" | |
1 | root to: redirect('/captchas') | |
2 | resources :captchas, only: [:index, :create] | |
3 | 3 | resources :users |
4 | 4 | end |
0 | test: | |
1 | service: Disk | |
2 | root: <%= Rails.root.join("tmp/storage") %> | |
3 | ||
4 | local: | |
5 | service: Disk | |
6 | root: <%= Rails.root.join("storage") %> | |
7 | ||
8 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) | |
9 | # amazon: | |
10 | # service: S3 | |
11 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> | |
12 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> | |
13 | # region: us-east-1 | |
14 | # bucket: your_own_bucket | |
15 | ||
16 | # Remember not to checkin your GCS keyfile to a repository | |
17 | # google: | |
18 | # service: GCS | |
19 | # project: your_project | |
20 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> | |
21 | # bucket: your_own_bucket | |
22 | ||
23 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) | |
24 | # microsoft: | |
25 | # service: AzureStorage | |
26 | # storage_account_name: your_account_name | |
27 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> | |
28 | # container: your_container_name | |
29 | ||
30 | # mirror: | |
31 | # service: Mirror | |
32 | # primary: local | |
33 | # mirrors: [ amazon, google, microsoft ] |
0 | class AddUser < ActiveRecord::Migration | |
0 | class AddUser < ActiveRecord::Migration[4.2] | |
1 | 1 | def change |
2 | 2 | create_table :users do |t| |
3 | 3 | t.string :name |
0 | # encoding: UTF-8 | |
1 | 0 | # This file is auto-generated from the current state of the database. Instead |
2 | 1 | # of editing this file, please use the migrations feature of Active Record to |
3 | 2 | # incrementally modify your database, and then regenerate this schema definition. |
10 | 9 | # |
11 | 10 | # It's strongly recommended that you check this file into your version control system. |
12 | 11 | |
13 | ActiveRecord::Schema.define(version: 20151226015155) do | |
12 | ActiveRecord::Schema.define(version: 2015_12_26_015155) do | |
14 | 13 | |
15 | 14 | create_table "users", force: :cascade do |t| |
16 | 15 | t.string "name" |