Browse Source

Refresh the rails project (#4306)

upgrade ruby to 2.6.0, rails to 5.2.2, upgrade all the gems, use more idiomatic ruby syles, use the default rails 5.2 configurations
Michael Spiz 6 years ago
parent
commit
90ec95ae29
29 changed files with 217 additions and 212 deletions
  1. 7 7
      frameworks/Ruby/rails/Gemfile
  2. 16 20
      frameworks/Ruby/rails/README.md
  3. 2 3
      frameworks/Ruby/rails/Rakefile
  4. 0 3
      frameworks/Ruby/rails/app/controllers/application_controller.rb
  5. 14 16
      frameworks/Ruby/rails/app/controllers/hello_world_controller.rb
  6. 3 0
      frameworks/Ruby/rails/app/models/application_record.rb
  7. 2 2
      frameworks/Ruby/rails/app/models/fortune.rb
  8. 2 2
      frameworks/Ruby/rails/app/models/world.rb
  9. 1 1
      frameworks/Ruby/rails/app/views/layouts/application.html.erb
  10. 3 2
      frameworks/Ruby/rails/config.ru
  11. 19 12
      frameworks/Ruby/rails/config/application.rb
  12. 2 5
      frameworks/Ruby/rails/config/boot.rb
  13. 1 0
      frameworks/Ruby/rails/config/credentials.yml.enc
  14. 4 4
      frameworks/Ruby/rails/config/environment.rb
  15. 23 14
      frameworks/Ruby/rails/config/environments/development.rb
  16. 28 36
      frameworks/Ruby/rails/config/environments/production.rb
  17. 5 8
      frameworks/Ruby/rails/config/environments/test.rb
  18. 8 0
      frameworks/Ruby/rails/config/initializers/application_controller_renderer.rb
  19. 25 0
      frameworks/Ruby/rails/config/initializers/content_security_policy.rb
  20. 5 0
      frameworks/Ruby/rails/config/initializers/cookies_serializer.rb
  21. 4 0
      frameworks/Ruby/rails/config/initializers/filter_parameter_logging.rb
  22. 0 7
      frameworks/Ruby/rails/config/initializers/secret_token.rb
  23. 0 3
      frameworks/Ruby/rails/config/initializers/session_store.rb
  24. 3 3
      frameworks/Ruby/rails/config/initializers/wrap_parameters.rb
  25. 31 3
      frameworks/Ruby/rails/config/locales/en.yml
  26. 1 0
      frameworks/Ruby/rails/config/master.key
  27. 5 58
      frameworks/Ruby/rails/config/routes.rb
  28. 2 2
      frameworks/Ruby/rails/rails-unicorn.dockerfile
  29. 1 1
      frameworks/Ruby/rails/rails.dockerfile

+ 7 - 7
frameworks/Ruby/rails/Gemfile

@@ -1,9 +1,9 @@
 source 'http://rubygems.org'
 
-gem 'mysql2', '0.4.10'
-gem 'unicorn', '5.4.0'
-gem 'puma', '3.9.1'
-gem 'activerecord-import', '0.18.1'
-gem 'activerecord', '5.1.5', :require => 'active_record'
-gem 'rails', '5.1.5'
-gem 'tzinfo-data', '1.2018.3'
+gem 'mysql2', '0.5.2'
+gem 'unicorn', '5.4.1'
+gem 'puma', '3.12.0'
+gem 'activerecord-import', '0.27.0'
+gem 'activerecord', '5.2.2', :require => 'active_record'
+gem 'rails', '5.2.2'
+gem 'tzinfo-data', '1.2018.7'

+ 16 - 20
frameworks/Ruby/rails/README.md

@@ -12,24 +12,20 @@ comparing a variety of web platforms.
 
 The tests were run with:
 
-* [Ruby 2.1.2](http://www.ruby-lang.org/)
-* [JRuby 1.7.13](http://jruby.org/)
-* [Rubinius 2.2.10](http://rubini.us/)
-* [Rails 4.1.4](http://rubyonrails.org/)
-* [Unicorn 4.8.3](http://unicorn.bogomips.org/)
-* [TorqBox 0.1.7](http://torquebox.org/torqbox/)
-* [Puma 3.9](http://puma.io/)
-* [Thin 1.6.2](http://code.macournoyer.com/thin/)
-* [MySQL 5.5](https://dev.mysql.com/)
+- [Ruby 2.6.0](http://www.ruby-lang.org/)
+- [Rails 5.2.2](http://rubyonrails.org/)
+- [Unicorn 5.4.1](http://unicorn.bogomips.org/)
+- [Puma 3.12](http://puma.io/)
+- [MySQL 5.5](https://dev.mysql.com/)
 
 ## Paths & Source for Tests
 
-* [JSON Serialization](app/controllers/hello_world_controller.rb): "/json"
-* [Single Database Query](app/controllers/hello_world_controller.rb): "/db", [World Model](app/models/world.rb)
-* [Multiple Database Queries](app/controllers/hello_world_controller.rb): "/db?queries={#}", [World Model](app/models/world.rb)
-* [Fortunes](app/controllers/hello_world_controller.rb): "/fortune" , [Fortunes Model](app/models/fortune.rb)
-* [Database Updates](app/controllers/hello_world_controller.rb): "/update?queries={#}", [World Model](app/models/world.rb)
-* [Plaintext](app/controllers/hello_world_controller.rb): "/plaintext"
+- [JSON Serialization](app/controllers/hello_world_controller.rb): "/json"
+- [Single Database Query](app/controllers/hello_world_controller.rb): "/db", [World Model](app/models/world.rb)
+- [Multiple Database Queries](app/controllers/hello_world_controller.rb): "/db?queries={#}", [World Model](app/models/world.rb)
+- [Fortunes](app/controllers/hello_world_controller.rb): "/fortune" , [Fortunes Model](app/models/fortune.rb)
+- [Database Updates](app/controllers/hello_world_controller.rb): "/update?queries={#}", [World Model](app/models/world.rb)
+- [Plaintext](app/controllers/hello_world_controller.rb): "/plaintext"
 
 ## Get Help
 
@@ -39,11 +35,11 @@ _No experts listed, yet. If you're an expert, add yourself!_
 
 ### Community
 
-* `#rubyonrails` IRC Channel ([irc.freenode.net](http://freenode.net/))
-* [Ruby on Rails Twitter](https://twitter.com/rails)
-* [Ruby on Rails Google Group](https://groups.google.com/forum/#!forum/rubyonrails-talk)
+- `#rubyonrails` IRC Channel ([irc.freenode.net](http://freenode.net/))
+- [Ruby on Rails Twitter](https://twitter.com/rails)
+- [Ruby on Rails Google Group](https://groups.google.com/forum/#!forum/rubyonrails-talk)
 
 ### Resources
 
-* [Ruby on Rails Source Code](https://github.com/rails/rails)
-* [PR: passenger-install-apache2-module doesn't work on ruby 2.0](https://github.com/FooBarWidget/passenger/pull/71)
+- [Ruby on Rails Source Code](https://github.com/rails/rails)
+- [PR: passenger-install-apache2-module doesn't work on ruby 2.0](https://github.com/FooBarWidget/passenger/pull/71)

+ 2 - 3
frameworks/Ruby/rails/Rakefile

@@ -1,7 +1,6 @@
-#!/usr/bin/env rake
 # Add your own tasks in files placed in lib/tasks ending in .rake,
 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
-require File.expand_path('../config/application', __FILE__)
+require_relative 'config/application'
 
-Hello::Application.load_tasks
+Rails.application.load_tasks

+ 0 - 3
frameworks/Ruby/rails/app/controllers/application_controller.rb

@@ -1,5 +1,2 @@
 class ApplicationController < ActionController::Base
-  # Prevent CSRF attacks by raising an exception.
-  # For APIs, you may want to use :null_session instead.
-  protect_from_forgery with: :exception
 end

+ 14 - 16
frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

@@ -1,18 +1,16 @@
-class HelloWorldController < ApplicationController
+# frozen_string_literal: true
 
+class HelloWorldController < ApplicationController
   def plaintext
-    response.headers['Content-Type'] = "text/plain"
-    render :plain => "Hello, World!"
+    render plain: 'Hello, World!'
   end
 
   def json
-    response.headers['Content-Type'] = "application/json"
-    render :json => {:message => "Hello, World!"}
+    render json: { message: 'Hello, World!' }
   end
 
   def db
-    response.headers['Content-Type'] = "application/json"
-    render :json => World.find(Random.rand(10000) + 1)
+    render json: World.find(Random.rand(1..10000))
   end
 
   def query
@@ -21,16 +19,16 @@ class HelloWorldController < ApplicationController
     queries = 500 if queries > 500
 
     results = (1..queries).map do
-      World.find(Random.rand(10000) + 1)
+      World.find(Random.rand(1..10000))
     end
-    response.headers['Content-Type'] = "application/json"
-    render :json => results
+
+    render json: results
   end
 
   def fortune
     @fortunes = Fortune.all.to_a
-    @fortunes << Fortune.new(:id => 0, :message => "Additional fortune added at request time.")
-    @fortunes = @fortunes.sort_by { |x| x.message }
+    @fortunes << Fortune.new(id: 0, message: 'Additional fortune added at request time.')
+    @fortunes = @fortunes.sort_by(&:message)
   end
 
   def update
@@ -41,11 +39,11 @@ class HelloWorldController < ApplicationController
     worlds = (1..queries).map do
       # get a random row from the database, which we know has 10000
       # rows with ids 1 - 10000
-      world = World.select(:id, :randomNumber).find(Random.rand(10000) + 1)
-      world.update_attribute(:randomNumber, Random.rand(10000) + 1)
+      world = World.select(:id, :randomNumber).find(Random.rand(1..10000))
+      world.update_attribute(:randomNumber, Random.rand(1..10000))
       world
     end
-    response.headers['Content-Type'] = "application/json"
-    render :json => worlds
+
+    render json: worlds
   end
 end

+ 3 - 0
frameworks/Ruby/rails/app/models/application_record.rb

@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+  self.abstract_class = true
+end

+ 2 - 2
frameworks/Ruby/rails/app/models/fortune.rb

@@ -1,3 +1,3 @@
-class Fortune < ActiveRecord::Base
+class Fortune < ApplicationRecord
   self.table_name = "Fortune"
-end
+end

+ 2 - 2
frameworks/Ruby/rails/app/models/world.rb

@@ -1,3 +1,3 @@
-class World < ActiveRecord::Base
+class World < ApplicationRecord
   self.table_name = "World"
-end
+end

+ 1 - 1
frameworks/Ruby/rails/app/views/layouts/application.html.erb

@@ -6,4 +6,4 @@
 <body>
 <%= yield %>
 </body>
-</html>
+</html>

+ 3 - 2
frameworks/Ruby/rails/config.ru

@@ -1,4 +1,5 @@
 # This file is used by Rack-based servers to start the application.
 
-require ::File.expand_path('../config/environment',  __FILE__)
-run Hello::Application
+require_relative 'config/environment'
+
+run Rails.application

+ 19 - 12
frameworks/Ruby/rails/config/application.rb

@@ -1,6 +1,17 @@
-require File.expand_path('../boot', __FILE__)
+require_relative 'boot'
 
-require 'rails/all'
+require "rails"
+# Pick the frameworks you want:
+require "active_model/railtie"
+# require "active_job/railtie"
+require "active_record/railtie"
+# require "active_storage/engine"
+require "action_controller/railtie"
+# require "action_mailer/railtie"
+require "action_view/railtie"
+# require "action_cable/engine"
+# require "sprockets/railtie"
+# require "rails/test_unit/railtie"
 
 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
@@ -8,17 +19,13 @@ Bundler.require(*Rails.groups)
 
 module Hello
   class Application < Rails::Application
-    # Settings in config/environments/* take precedence over those specified here.
-    # Application configuration should go into files in config/initializers
-    # -- all .rb files in that directory are automatically loaded.
-
-    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
-    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
-    # config.time_zone = 'Central Time (US & Canada)'
+    # Initialize configuration defaults for originally generated Rails version.
+    config.load_defaults 5.2
 
-    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
-    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
-    # config.i18n.default_locale = :de
+    # Settings in config/environments/* take precedence over those specified here.
+    # Application configuration can go into files in config/initializers
+    # -- all .rb files in that directory are automatically loaded after loading
+    # the framework and any gems in your application.
 
     config.action_dispatch.default_headers.merge!('Date' => Time.now.httpdate, 'Server' => 'WebServer')
   end

+ 2 - 5
frameworks/Ruby/rails/config/boot.rb

@@ -1,6 +1,3 @@
-require 'rubygems'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
 
-# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+require 'bundler/setup' # Set up gems listed in the Gemfile.

+ 1 - 0
frameworks/Ruby/rails/config/credentials.yml.enc

@@ -0,0 +1 @@
+L37M3yBc/U1EAKqzbKEmv6tYoOK6dGK22vsavvaysN0QNTbhU/6Bwhe8bnKmBzQsQcHvS6YldUdkCpjBCjLyGwD0ojY5cQLbC/XdXiC2JBufDleRXotjBNDOYZ5nQUKgOzjocmLEacpNqF5VllJ3f6XkZzmxPKtqkaAwKMnolL5XIEv6Y6MyWzAUs/DvsPmnEEOsMOOt2U0fx56gyKYHXzzZiSbpShP8DknXSMht7qBKPOC+CAdb5OH/teoMQSMYe2g/xvfLpeU0zO6k/0zdaJL+w9cd4gJ/O4gkstPwdfaCXQv3SX4SH9PEsE2Cv8cFVbfJCI/9uAcpGAm3QFi2Lx4mqfGaeKK6YaD1OFoM7Oyp/jGITYq7pQYidXRQ8ngvX7vkSpwBHTmiMR8ddcT9Xk5BMR990FyHifSF--qiNe411303/p1rd4--++5mTb8wBXXW2KRdvF8S/g==

+ 4 - 4
frameworks/Ruby/rails/config/environment.rb

@@ -1,5 +1,5 @@
-# Load the rails application
-require File.expand_path('../application', __FILE__)
+# Load the Rails application.
+require_relative 'application'
 
-# Initialize the rails application
-Hello::Application.initialize!
+# Initialize the Rails application.
+Rails.application.initialize!

+ 23 - 14
frameworks/Ruby/rails/config/environments/development.rb

@@ -9,12 +9,23 @@ Rails.application.configure do
   # Do not eager load code on boot.
   config.eager_load = false
 
-  # Show full error reports and disable caching.
-  config.consider_all_requests_local       = true
-  config.action_controller.perform_caching = false
+  # Show full error reports.
+  config.consider_all_requests_local = true
 
-  # Don't care if the mailer can't send.
-  config.action_mailer.raise_delivery_errors = false
+  # Enable/disable caching. By default caching is disabled.
+  # Run rails dev:cache to toggle caching.
+  if Rails.root.join('tmp', 'caching-dev.txt').exist?
+    config.action_controller.perform_caching = true
+
+    config.cache_store = :memory_store
+    config.public_file_server.headers = {
+      'Cache-Control' => "public, max-age=#{2.days.to_i}"
+    }
+  else
+    config.action_controller.perform_caching = false
+
+    config.cache_store = :null_store
+  end
 
   # Print deprecation notices to the Rails logger.
   config.active_support.deprecation = :log
@@ -22,16 +33,14 @@ Rails.application.configure do
   # Raise an error on page load if there are pending migrations.
   config.active_record.migration_error = :page_load
 
-  # Debug mode disables concatenation and preprocessing of assets.
-  # This option may cause significant delays in view rendering with a large
-  # number of complex assets.
-  config.assets.debug = true
+  # Highlight code that triggered database queries in logs.
+  config.active_record.verbose_query_logs = true
 
-  # Adds additional error checking when serving assets at runtime.
-  # Checks for improperly declared sprockets dependencies.
-  # Raises helpful error messages.
-  config.assets.raise_runtime_errors = true
 
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
-end
+
+  # Use an evented file watcher to asynchronously detect changes in source code,
+  # routes, locales, etc. This feature depends on the listen gem.
+  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end

+ 28 - 36
frameworks/Ruby/rails/config/environments/production.rb

@@ -14,51 +14,37 @@ Rails.application.configure do
   config.consider_all_requests_local       = false
   config.action_controller.perform_caching = true
 
-  # Enable Rack::Cache to put a simple HTTP cache in front of your application
-  # Add `rack-cache` to your Gemfile before enabling this.
-  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
-  # config.action_dispatch.rack_cache = true
+  # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+  # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+  # config.require_master_key = true
 
-  # Disable Rails's static asset server (Apache or nginx will already do this).
-  config.serve_static_assets = false
+  # Disable serving static files from the `/public` folder by default since
+  # Apache or NGINX already handles this.
+  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
 
-  # Compress JavaScripts and CSS.
-  # config.assets.js_compressor = :uglifier
-  # config.assets.css_compressor = :sass
-
-  # Do not fallback to assets pipeline if a precompiled asset is missed.
-  config.assets.compile = false
-
-  # Generate digests for assets URLs.
-  config.assets.digest = true
-
-  # `config.assets.precompile` has moved to config/initializers/assets.rb
+  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+  # config.action_controller.asset_host = 'http://assets.example.com'
 
   # Specifies the header that your server uses for sending files.
-  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
-  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
 
   # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
   # config.force_ssl = true
 
-  # Set to :debug to see everything in the log.
-  config.log_level = :error # :info
+  # Use the lowest log level to ensure availability of diagnostic information
+  # when problems arise.
+  config.log_level = :error
 
   # Prepend all log lines with the following tags.
-  # config.log_tags = [ :subdomain, :uuid ]
-
-  # Use a different logger for distributed setups.
-  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+  config.log_tags = [ :request_id ]
 
   # Use a different cache store in production.
   # config.cache_store = :mem_cache_store
 
-  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
-  # config.action_controller.asset_host = "http://assets.example.com"
-
-  # Ignore bad email addresses and do not raise email delivery errors.
-  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
-  # config.action_mailer.raise_delivery_errors = false
+  # Use a real queuing backend for Active Job (and separate queues per environment)
+  # config.active_job.queue_adapter     = :resque
+  # config.active_job.queue_name_prefix = "testrails522_#{Rails.env}"
 
   # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
   # the I18n.default_locale when a translation cannot be found).
@@ -67,13 +53,19 @@ Rails.application.configure do
   # Send deprecation notices to registered listeners.
   config.active_support.deprecation = :notify
 
-  # Disable automatic flushing of the log to improve performance.
-  # config.autoflush_log = false
-
   # Use default logging formatter so that PID and timestamp are not suppressed.
   config.log_formatter = ::Logger::Formatter.new
 
+  # Use a different logger for distributed setups.
+  # require 'syslog/logger'
+  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+  if ENV["RAILS_LOG_TO_STDOUT"].present?
+    logger           = ActiveSupport::Logger.new(STDOUT)
+    logger.formatter = config.log_formatter
+    config.logger    = ActiveSupport::TaggedLogging.new(logger)
+  end
+
   # Do not dump schema after migrations.
   config.active_record.dump_schema_after_migration = false
-  
-end
+end

+ 5 - 8
frameworks/Ruby/rails/config/environments/test.rb

@@ -12,9 +12,11 @@ Rails.application.configure do
   # preloads Rails for running tests, you may have to set it to true.
   config.eager_load = false
 
-  # Configure static asset server for tests with Cache-Control for performance.
-  config.serve_static_assets  = true
-  config.static_cache_control = 'public, max-age=3600'
+  # Configure public file server for tests with Cache-Control for performance.
+  config.public_file_server.enabled = true
+  config.public_file_server.headers = {
+    'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+  }
 
   # Show full error reports and disable caching.
   config.consider_all_requests_local       = true
@@ -26,11 +28,6 @@ Rails.application.configure do
   # Disable request forgery protection in test environment.
   config.action_controller.allow_forgery_protection = false
 
-  # Tell Action Mailer not to deliver emails to the real world.
-  # The :test delivery method accumulates sent emails in the
-  # ActionMailer::Base.deliveries array.
-  config.action_mailer.delivery_method = :test
-
   # Print deprecation notices to the stderr.
   config.active_support.deprecation = :stderr
 

+ 8 - 0
frameworks/Ruby/rails/config/initializers/application_controller_renderer.rb

@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+#   ApplicationController.renderer.defaults.merge!(
+#     http_host: 'example.org',
+#     https: false
+#   )
+# end

+ 25 - 0
frameworks/Ruby/rails/config/initializers/content_security_policy.rb

@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy
+# For further information see the following documentation
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+# Rails.application.config.content_security_policy do |policy|
+#   policy.default_src :self, :https
+#   policy.font_src    :self, :https, :data
+#   policy.img_src     :self, :https, :data
+#   policy.object_src  :none
+#   policy.script_src  :self, :https
+#   policy.style_src   :self, :https
+
+#   # Specify URI for violation reports
+#   # policy.report_uri "/csp-violation-report-endpoint"
+# end
+
+# If you are using UJS then enable automatic nonce generation
+# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+# Report CSP violations to a specified URI
+# For further information see the following documentation:
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+# Rails.application.config.content_security_policy_report_only = true

+ 5 - 0
frameworks/Ruby/rails/config/initializers/cookies_serializer.rb

@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json

+ 4 - 0
frameworks/Ruby/rails/config/initializers/filter_parameter_logging.rb

@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]

+ 0 - 7
frameworks/Ruby/rails/config/initializers/secret_token.rb

@@ -1,7 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Your secret key for verifying the integrity of signed cookies.
-# If you change this key, all old signed cookies will become invalid!
-# Make sure the secret is at least 30 characters and all random,
-# no regular words or you'll be exposed to dictionary attacks.
-Hello::Application.config.secret_token = '926e786d885e710c50bf02bc2e9d6d8dae9fbe566a517c030acf793f4d4e6cb6c9dc9cce0056ab031a2e045dc3c9e98071b2b20825df4c5e09f6554b1785c668'

+ 0 - 3
frameworks/Ruby/rails/config/initializers/session_store.rb

@@ -1,3 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-Rails.application.config.session_store :cookie_store, key: '_rails_session'

+ 3 - 3
frameworks/Ruby/rails/config/initializers/wrap_parameters.rb

@@ -5,10 +5,10 @@
 
 # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
 ActiveSupport.on_load(:action_controller) do
-  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
+  wrap_parameters format: [:json]
 end
 
 # To enable root element in JSON for ActiveRecord objects.
 # ActiveSupport.on_load(:active_record) do
-#  self.include_root_in_json = true
-# end
+#   self.include_root_in_json = true
+# end

+ 31 - 3
frameworks/Ruby/rails/config/locales/en.yml

@@ -1,5 +1,33 @@
-# Sample localization file for English. Add more files in this directory for other locales.
-# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+#     I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+#     <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+#     I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+#   'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
 
 en:
-  hello: "Hello world"
+  hello: 'Hello world'

+ 1 - 0
frameworks/Ruby/rails/config/master.key

@@ -0,0 +1 @@
+1227dc3827f01fa05f0aadb66063e2ba

+ 5 - 58
frameworks/Ruby/rails/config/routes.rb

@@ -1,63 +1,10 @@
 Rails.application.routes.draw do
-  # The priority is based upon order of creation: first created -> highest priority.
-  # See how all your routes lay out with "rake routes".
-
-  # You can have the root of your site routed with "root"
-  # root 'welcome#index'
-
-  # Example of regular route:
-  #   get 'products/:id' => 'catalog#view'
-
-  # Example of named route that can be invoked with purchase_url(id: product.id)
-  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
-
-  # Example resource route (maps HTTP verbs to controller actions automatically):
-  #   resources :products
-
-  # Example resource route with options:
-  #   resources :products do
-  #     member do
-  #       get 'short'
-  #       post 'toggle'
-  #     end
-  #
-  #     collection do
-  #       get 'sold'
-  #     end
-  #   end
-
-  # Example resource route with sub-resources:
-  #   resources :products do
-  #     resources :comments, :sales
-  #     resource :seller
-  #   end
-
-  # Example resource route with more complex sub-resources:
-  #   resources :products do
-  #     resources :comments
-  #     resources :sales do
-  #       get 'recent', on: :collection
-  #     end
-  #   end
-
-  # Example resource route with concerns:
-  #   concern :toggleable do
-  #     post 'toggle'
-  #   end
-  #   resources :posts, concerns: :toggleable
-  #   resources :photos, concerns: :toggleable
-
-  # Example resource route within a namespace:
-  #   namespace :admin do
-  #     # Directs /admin/products/* to Admin::ProductsController
-  #     # (app/controllers/admin/products_controller.rb)
-  #     resources :products
-  #   end
+  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
 
   get "hello_world/json"
   get "hello_world/db"
   get "hello_world/query"
-  get "fortune" => "hello_world#fortune"
-  get "update" => "hello_world#update"
-  get "plaintext" => "hello_world#plaintext"
-end
+  get "fortune", to: "hello_world#fortune"
+  get "update", to: "hello_world#update"
+  get "plaintext", to: "hello_world#plaintext"
+end

+ 2 - 2
frameworks/Ruby/rails/rails-unicorn.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.6
 
 RUN apt update -yqq && apt install -yqq nginx
 
@@ -9,4 +9,4 @@ WORKDIR /rails
 RUN bundle install --jobs=4 --gemfile=/rails/Gemfile --path=/rails/rails/bundle
 
 CMD nginx -c /rails/config/nginx.conf && \
-    DB_HOST=tfb-database bundle exec unicorn_rails -E production -c config/unicorn.rb
+  DB_HOST=tfb-database bundle exec unicorn_rails -E production -c config/unicorn.rb

+ 1 - 1
frameworks/Ruby/rails/rails.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.6
 
 ADD ./ /rails