Modification to Gemfile during bundle update rails
actionpack and faraday were added in order to address dependency issues with omniauth-stripe-connect", ">=2.4.0"
Changed the version of postgres gem to pg "0.21.0", to prevent an ActiveRecord error when the server is run.
quiet_assets gem was deleted from the development block since it is deprecated and no longer needed. The Rails 5 asset pipeline now supports a quiet option which suppresses output of asset requests in development when config.assets.quiet = true is enabled in # config/environments/development.rbhttps://rossta.net/blog/quiet-assets-in-rails-5.html
Rails 5 no longer uses the app constant in config files. This removes the class level abstraction of an application.
Nextrequest::Application in routes.rb, development.rb, production.rb, test.rb, and session_store.rb is replaced by Rails.application
"The class level abstraction makes sense when the Rails application is a singleton, but in the future if there are multiple applications per class, then it does not make sense to configure the entire class, but instead makes sense to configure a particular application instance. In this vein, I've replaced the app_const with the canonical Rails.application"
https://github.com/rails/rails/pull/10389
Bundler.require(:default, Rails.env) changes to Bundler.require(*Rails.groups). This uses the RAILS_GROUPS env variable and loads all Rails groups based on the Rails environment.
Keep require 'rails/all', which is a rails default and require 'obscenity/active_model' - which is part of the configuration for the 'obscenity', which filters profanity.
keep the following configuration but double check that it does not need to be placed in manifest.js or assets.rb
Keep config.autoload_paths += %W(#{config.root}/lib) - which is configuration for the gridder gem, which allows emails to be received in the app.
Keep config.active_job.queue_adapter = :sidekiq - which is part of the configuration for sidekiq gem
Investigate if the code below should stay in application.rb or be moved to a file in the assets folder or to config/initializers/assets.rb. For now (March 30, 2018), this stays in application.rb.
# 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)'
# 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
* `config.active_record.raise_in_callbacks = true` is no longer needed. In Rails 4 Active Record suppressed errors raised within after_rollback or after_commit callbacks and only printed them to the logs. In Rails 5, these errors will no longer be suppressed. Instead, the errors will propagate normally just like in other Active Record callbacks.
config/secrets.yml
the new secret keys provided by the update were declined and the <%= ENV["SECRET_TOKEN"] %> were kept.
Wording was changed from rake secret to rails secret for generate a secure secret key.
puma.rb
Since the Heroku guide for deploying a rails app with Puma Web Server remains the same and the puma_worker_killer's gem method for rolling restarts has not changed, I think the only change needed in this file is to add the plugin :tmp_restart which allows puma to be restarted by the rails restart command.
The above code checks if the file tmp/caching-dev.txt is present and then use :mem_cache_store to enable caching only if the file is found. Rails 5 has introduced a new command to create development cache and help us test how caching behaves in development mode. rails dev:cachehttps://blog.bigbinary.com/2016/01/25/caching-in-development-environment-in-rails5.html
config.active_record.migration_error = :page_load - This is currently set to false in our application. Setting to :page_load will raise an error on each page refresh if there are migrations that are pending.
Take out config.action_controller.include_all_helpers = true - configures whether all view helpers are available everywhere or are scoped to the corresponding controller. When set to true UsersHelper methods are available everywhere. The default configuration behavior (when this option is not explicitly set to true or false) is that all view helpers are available to each controller.
The above is not needed currently but can be useful in the future for raising translation errors in views/helpers. Rails 5 does not explicitly set this, so we can delete it from application.rb/development.rb/test.rb
Add the following to development.rb
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# 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
Keep as is in development.rb
config.eager_load = false - Don't eager load code on boot.
config.consider_all_requests_local = true - rue by default in development and test environments, and false in production mode. If true then any error will cause detailed debugging information to be dumped in the HTTP response, and the Rails::Info controller will show the application runtime context in /rails/info/properties. config.action_mailer.delivery_method = :letter_opener - configuration for letter_opener gem which allows email to pop up in the browser instead of being sent in development mode.
config.action_mailer.preview_path = "#{Rails.root}/test/mailers/previews" - used for testing devise mailer
config.active_support.deprecation = :log - print deprecation notices to the Rails logger
config.assets.debug = true - disables concatenation and preprocessing of assets
config.assets.quiet = true - suppresses output of asset requests in development
config.action_mailer.raise_delivery_errors = true - Rails 5 ships with default set as false. We want to keep this set to true.
config.action_mailer.default_url_options = { host: 'localhost:3000' }config.middleware.use Rack::Attack configuration for rack-attack gem which blocks & throttles abusive requests. The rules for blocking and throttling are defined in rack-attack.rb.
Check if the upgrade to Rails 5 requires the code below to be moved to another file.
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/ - allows fonts to be placed outside of app/assets/fonts and enables support on different devices.
config.assets.precompile += %w( icons/) - allows icons to be precompiled
config.assets.precompile += ["styleguide.html"] - allows styleguide.html to be precompiled
https://github.com/livingstyleguide/livingstyleguide
config.lograge.enabled = true - added to configure lograge gem which replaces Rails' request logging by reducing the output per request to a single line with all the important information, while removing the from the Rails default output.
config.lograge.custom_options = lambda do |event|
params = event.payload[:params].reject do |k|
['controller', 'action'].include? k
end
{ "params" => params }
end
The code above should be maintained since it adds customization to lograge so that the request parameters is accessible in the logs.
Keep the smtp_settings settings for ActionMailer and Rack::MiniProfiler.config.start_hidden = true, which is part of the setting for the "rack-mini-profiler" gem which is a middleware that displays speed badge for every html page.
production.rb
Add to production.rb
config.active_record.dump_schema_after_migration = false - prevents the schema from being dump ed after migrations
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# 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 = "nextrequest_#{Rails.env}"
config.action_mailer.perform_caching = false
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# 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
Does the above code need to be commented out?
Take out/Modify
Update config.serve_static_files = false with config.public_file_server.enabled = falseconfig.action_controller.include_all_helpers = true - The default configuration behavior in Rails 5 (when this option is not explicitly set to true or false) is that all view helpers are available to each controller.
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
config.assets.precompile and config.assets.version have moved to config/initializers/assets.rb
config.log_level = :info in Rails 4 and Rails 5 the default is config.log_level = :debug - The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, corresponding to the log level numbers from 0 up to 5, respectively.
Update config.log_tags = [ :subdomain, :uuid ] with config.log_tags = [ :request_id ]as the:request_id` log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requests
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
Delete the above comment.
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
Delete the above comment.
# Disable automatic flushing of the log to improve performance.
- # config.autoflush_log = false
The above code is used to precompile additional assets. Check if this is where the code should remain in Rails 5.
config.action_mailer.default_url_options = { host: "www.nextrequest.com" }config.i18n.fallbacks = true - Enable locale fallbacks for I18n (no change between Rails 4 and 5)
config.active_support.deprecation = :notify - Send deprecation notices to registered listeners (no change between Rails 4 and 5)
config.log_formatter = ::Logger::Formatter.new - Use default logging formatter so that PID and timestamp are not suppressed. (no change between Rails 4 and 5)
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
params = event.payload[:params].reject do |k|
['controller', 'action'].include? k
end
{ "params" => params }
end
The code above is used to configure lograge gem which replaces Rails' request logging by reducing the output per request to a single line with all the important information, while removing the from the Rails default output.
config.middleware.use Rack::Attack - configuration for rack-attack gem which blocks & throttles abusive requests. The rules for blocking and throttling are defined in rack-attack.rb.
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
Change the above with what is below
# Prepend all log lines with the following tags.
#config.log_tags = [ :request_id ]```
The :request_id log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requests. Whether you are using components that are setting request ID or not, all production applications can benefit from the additional debugging information of having a unique identifier for all requests.
# 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
test.rb
Add in test.rb
config.action_mailer.perform_caching = false - mailer template will not perform fragment caching in test environment.
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
Modify
Update # Configure static asset server for tests with Cache-Control for performance. with
# Configure public file server for tests with Cache-Control for performance.
Update config.serve_static_files = true with config.public_file_server.enabled = true as serve_static_files is deprecated in rails Rails 5, wherepublic_file_serveris used to unify the static options under thepublic_file_serverwing.config.public_file_server.enabled` configures Rails to serve static files from the public directory.
Update config.static_cache_control = "public, max-age=3600" with
Maintain in test.rb
config.assets.debug = true - disables concatenation and preprocessing of assets
config.consider_all_requests_local = true - when set to true then any error will cause detailed debugging information to be dumped in the HTTP response, and the Rails::Info controller will show the application runtime context in /rails/info/properties.
config.action_controller.perform_caching = true - enables caching in test environment.
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# 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
config.action_mailer.default_url_options = { host: 'localhost:3000' } - set default host that will be used for mailers in test environment.
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Delete in test.rb
config.action_controller.include_all_helpers = true - In Rails 5 the default configuration behavior (when this option is not explicitly set to true or false) is that all view helpers are available to each controller.
config.active_record.raise_in_transactional_callbacks = true - Active Record no longer suppresses errors raised within after_rollback or after_commit callbacks in Rails 5. Hence I don't think this line is needed.
boot.rb
Rails 5 uses require 'bundler/setup' without checkingif File.exist?(ENV['BUNDLE_GEMFILE']) . The if check was causing Gemfile related errors. https://github.com/rails/rails/pull/16046
config/initializers/cookies_serializer.rb
Replace Nextrequest::Application.config.session_store :cookie_store, key: '_recordquest_session' with Rails.application.config.session_store :cookie_store, key: '_nextrequest_session' - the code specifies what class to use to store the session.
initializers/wrap_parameters.rb
Replace wrap_parameters format: [:json] if respond_to?(:wrap_parameters) with wrap_parameters format: [:json] - as checking if controller responds to wrap_parameter is not longer required. Keep the rest of the code as is.
initializers/mime_types.rb
Delete # Mime::Type.register_alias "text/html", :iphone - Rails 5 takes out this line so as not to encourage the use of aliases.
locales/en.yml
Keep as is. Local changes were made to this file for testing and error handling purposes.
Rakefile
Update require File.expand_path("../config/application", __FILE__) with require_relative "config/application" and Nextrequest::Application.load_tasks with Rails.application.load_tasks and keep the code below, which was added to added rerun rspec to cut down on failing tests
New files that Rails 5 ships with
assets/config/manifest.js - tells Sprockets which files to require in order to build a single CSS or JavaScript file. Previously you didn’t need to include fonts and images in your precompiled assets list. Link your JS and CSS directories as well as any other directories like images, fonts, sounds etc inside this file. http://eileencodes.com/posts/the-sprockets-4-manifest/assets/javascripts/cable.js - Added for Action Cable
channels/application_cable/channel.rb - Added for Action Cable. Used to place shared logic between channels.
app/jobs/application_job.rb - the jobs folder was previously created whenever a new job was created, but now it exists by default. application_job.rb is a global file from which jobs inherit.
app/mailers/application_mailer.rb - Mailers inherit from ApplicationMailer in Rails 5.
layouts/mailer.html.erb - Added for ActionMailer
layouts/mailer.text.erb - Added for ActionMailer
app/models/application_record.rb - ApplicationRecord is a new superclass for all app models, analogous to app controllers subclassing. This provides a single point of entry for customizations and extensions needed for an application. It prevents the need for monkey patching ActiveRecord::Base when we want to add extra functionality to Active Record. https://blog.bigbinary.com/2015/12/28/application-record-in-rails-5.htmlbin/update - Adds the ability to run tasks and tests through bin/rails instead of rake. Run Run bin/rails to see the list of commands available.
config/cable.yml - contains settings for Action Cable.
config/initializers/new_framework_defaults.rb - contains settings used for backwards compatibility. https://blog.bigbinary.com/2016/08/18/new-framework-defaults-in-rails-5-to-make-upgrade-easier.htmlconfig/puma.rb - Puma is now the default development web server
config/spring.rb - Spring is a Rails application preloader. It speeds up development by keeping the application running in the background so it does't have to be booted every time a test, a rake task or migration is run.
Config files removed in Rails 5
config/initializers/to_time_preserves_timezone.rb - ActiveSupport.to_time_preserves_timezone = false is instead set in new_framework_defaults.rb. Set this to true in order to preserve the timezone of the receiver.
Rails 5 Readme comes in markdown format instead of rdoc.
[ ] config/environments/development.rb -> look into listen gem/, config.assets.quiet = true and config.file_watcher
[ ] config/environments/production.rb -> config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
[ ] Move config.assets.precompile and config.assets.version to config/initializers/assets.rb
[ ] In config/environments/production.rb add config.log_level = :debug
[ ] Check if config.log_tags = [ :subdomain, :uuid ] was an internal change and if it is still needed.
[ ] In Precompile additional assets - check what the assets file has
[ ] In config/environments/production.rb check if disable automatic flushing of the log to improve performance is still needed (config.autoflush_log = false)
[ ] Keep the lograge that is currently there and add the comments.
[ ] Check if config.action_controller.include_all_helpers = true should be deleted from config/environments/production.rb, test.rb, development.rb
[ ] For config/test go through the above steps
[ ] In mime_types.rb check if Mime::Type.register_alias was added internally and whether it is still supported
[ ] In session_store.rb, see what the change in accomplishes (Nextrequest vs Rails)
[ ] In wrap_parameters.rb check to see if wrap_parameters format: [:json] if respond_to?(:wrap_parameters) was added internally and if it is still needed
*[ ] In /bin/rails APP_PATH = File.expand_path('../config/application', __dir__) check what the change with FILE accomplishes.
Modification to Gemfile during bundle update rails
actionpack
andfaraday
were added in order to address dependency issues withomniauth-stripe-connect", ">=2.4.0"
pg "0.21.0"
, to prevent an ActiveRecord error when the server is run.quiet_assets
gem was deleted from the development block since it is deprecated and no longer needed. The Rails 5 asset pipeline now supports a quiet option which suppresses output of asset requests in development whenconfig.assets.quiet = true
is enabled in# config/environments/development.rb
https://rossta.net/blog/quiet-assets-in-rails-5.htmlConfiguration Files
See the Railsdiff website to for line by line changes in configuration files between different versions of Rails. The richonrails website provides a summarized version of changes in config files introduced in Rails 5. http://railsdiff.org/4.2.10/5.0.0 https://richonrails.com/articles/the-rails-5-0-default-files
Rails 5 define relative paths with dir in
config/boot.rb
andbin/rails
. Using__dir__
instead of__File__
gets rid of redundant../
https://bogdanvlviv.com/posts/ruby/with-__dir__-we-can-restore-order-in-the-universe.html
Rails 5 no longer uses the app constant in config files. This removes the class level abstraction of an application.
Nextrequest::Application
inroutes.rb
,development.rb
,production.rb
,test.rb
, andsession_store.rb
is replaced byRails.application
"The class level abstraction makes sense when the Rails application is a singleton, but in the future if there are multiple applications per class, then it does not make sense to configure the entire class, but instead makes sense to configure a particular application instance. In this vein, I've replaced the app_const with the canonical Rails.application" https://github.com/rails/rails/pull/10389Rails 5 uses
require_relative
inconfig.rb
,config/application.rb
,environment.rb
, andRakefile
instead ofrequire + File.expand_path
as this reads better. https://github.com/rails/rails/commit/fbf3411b11762db4bf80dc8695863e623515c701config/application.rb
Bundler.require(:default, Rails.env)
changes toBundler.require(*Rails.groups)
. This uses the RAILS_GROUPS env variable and loads all Rails groups based on the Rails environment.Keep
require 'rails/all'
, which is a rails default andrequire 'obscenity/active_model'
- which is part of the configuration for the'obscenity'
, which filters profanity.Keep
config.autoload_paths += %W(#{config.root}/lib)
- which is configuration for thegridder
gem, which allows emails to be received in the app.Keep
config.active_job.queue_adapter = :sidekiq
- which is part of the configuration forsidekiq
gemInvestigate if the code below should stay in application.rb or be moved to a file in the assets folder or to config/initializers/assets.rb. For now (March 30, 2018), this stays in application.rb.
Keep configuration for paperclip
Delete the following commented out lines
config/secrets.yml
the new secret keys provided by the update were declined and the
<%= ENV["SECRET_TOKEN"] %>
were kept.Wording was changed from
rake secret
torails secret
for generate a secure secret key.puma.rb
Since the Heroku guide for deploying a rails app with Puma Web Server remains the same and the
puma_worker_killer
's gem method for rolling restarts has not changed, I think the only change needed in this file is to add theplugin :tmp_restart
which allows puma to be restarted by therails restart
command.workers ENV.fetch("WEB_CONCURRENCY") { 2 }
is commented out. This allows JRuby and windows devs to use the Rails 5 configuration without modification. https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server https://github.com/schneems/puma_worker_killer https://github.com/rails/rails/commit/5563c329eee5febc22a3330e16fe8a6899d42fe2The default puma.rb Rails 5 file has the following code
config/environments/development.rb
Take out
config.action_controller.perform_caching = false
and insert the code below which enables/disables caching in development mode.The above code checks if the file tmp/caching-dev.txt is present and then use :mem_cache_store to enable caching only if the file is found. Rails 5 has introduced a new command to create development cache and help us test how caching behaves in development mode.
rails dev:cache
https://blog.bigbinary.com/2016/01/25/caching-in-development-environment-in-rails5.htmlconfig.active_record.migration_error = :page_load
- This is currently set to false in our application. Setting to :page_load will raise an error on each page refresh if there are migrations that are pending.Take out
config.action_controller.include_all_helpers = true
- configures whether all view helpers are available everywhere or are scoped to the corresponding controller. When set to true UsersHelper methods are available everywhere. The default configuration behavior (when this option is not explicitly set to true or false) is that all view helpers are available to each controller. The above is not needed currently but can be useful in the future for raising translation errors in views/helpers. Rails 5 does not explicitly set this, so we can delete it from application.rb/development.rb/test.rbAdd the following to development.rb
config.eager_load = false
- Don't eager load code on boot.config.consider_all_requests_local = true
- rue by default in development and test environments, and false in production mode. If true then any error will cause detailed debugging information to be dumped in the HTTP response, and the Rails::Info controller will show the application runtime context in /rails/info/properties.config.action_mailer.delivery_method = :letter_opener
- configuration forletter_opener
gem which allows email to pop up in the browser instead of being sent in development mode.config.action_mailer.preview_path = "#{Rails.root}/test/mailers/previews"
- used for testing devise mailerconfig.active_support.deprecation = :log
- print deprecation notices to the Rails loggerconfig.assets.debug = true
- disables concatenation and preprocessing of assetsconfig.assets.quiet = true
- suppresses output of asset requests in developmentconfig.action_mailer.raise_delivery_errors = true
- Rails 5 ships with default set as false. We want to keep this set to true.config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.middleware.use Rack::Attack
configuration forrack-attack
gem which blocks & throttles abusive requests. The rules for blocking and throttling are defined inrack-attack.rb
.Check if the upgrade to Rails 5 requires the code below to be moved to another file.
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
- allows fonts to be placed outside of app/assets/fonts and enables support on different devices.config.assets.precompile += %w( icons/)
- allows icons to be precompiledconfig.assets.precompile += ["styleguide.html"]
- allows styleguide.html to be precompiled https://github.com/livingstyleguide/livingstyleguideconfig.lograge.enabled = true
- added to configurelograge
gem which replaces Rails' request logging by reducing the output per request to a single line with all the important information, while removing the from the Rails default output.The code above should be maintained since it adds customization to lograge so that the request parameters is accessible in the logs.
environment.rb
Update
require File.expand_path('../application', __FILE__) with
require_relative 'application'and
Nextrequest::Application.initialize!with
Rails.application.initialize!`Keep the smtp_settings settings for ActionMailer and
Rack::MiniProfiler.config.start_hidden = true
, which is part of the setting for the"rack-mini-profiler"
gem which is a middleware that displays speed badge for every html page.production.rb
config.active_record.dump_schema_after_migration = false
- prevents the schema from being dump ed after migrationsDoes the above code need to be commented out?
config.serve_static_files = false
withconfig.public_file_server.enabled = false
config.action_controller.include_all_helpers = true
- The default configuration behavior in Rails 5 (when this option is not explicitly set to true or false) is that all view helpers are available to each controller.config.assets.precompile
andconfig.assets.version
have moved to config/initializers/assets.rbconfig.log_level = :info
in Rails 4 and Rails 5 the default isconfig.log_level = :debug
- The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, corresponding to the log level numbers from 0 up to 5, respectively.Update
config.log_tags = [ :subdomain, :uuid ]
with config.log_tags = [ :request_id ]as the
:request_id` log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requestsDelete the above comment.
Delete the above comment.
Delete the above comment.
Delete
config.action_controller.include_all_helpers = true
config.assets.digest = true
- Generate digests for assets URLs.The above code is used to precompile additional assets. Check if this is where the code should remain in Rails 5.
config.action_mailer.default_url_options = { host: "www.nextrequest.com" }
config.i18n.fallbacks = true
- Enable locale fallbacks for I18n (no change between Rails 4 and 5)config.active_support.deprecation = :notify
- Send deprecation notices to registered listeners (no change between Rails 4 and 5)config.log_formatter = ::Logger::Formatter.new
- Use default logging formatter so that PID and timestamp are not suppressed. (no change between Rails 4 and 5)The code above is used to configure
lograge
gem which replaces Rails' request logging by reducing the output per request to a single line with all the important information, while removing the from the Rails default output.config.middleware.use Rack::Attack
- configuration for rack-attack gem which blocks & throttles abusive requests. The rules for blocking and throttling are defined in rack-attack.rb.Change the above with what is below
The
:request_id
log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requests. Whether you are using components that are setting request ID or not, all production applications can benefit from the additional debugging information of having a unique identifier for all requests.https://github.com/rails/rails/commit/81d3bec460715d5ca9b039b72db080a733867299
test.rb
Add in test.rb
config.action_mailer.perform_caching = false
- mailer template will not perform fragment caching in test environment.Modify
Update
# Configure static asset server for tests with Cache-Control for performance.
with# Configure public file server for tests with Cache-Control for performance.
Update
config.serve_static_files = true
withconfig.public_file_server.enabled = true
asserve_static_files
is deprecatedin rails Rails 5, where
public_file_serveris used to unify the static options under the
public_file_serverwing.
config.public_file_server.enabled` configures Rails to serve static files from the public directory.Update
config.static_cache_control = "public, max-age=3600"
withconfig.static_cache_control
is deprecated in Rails 5 in favor ofconfig.public_file_server.headers
. The above code adds the ability of returning arbitrary headers to ActionDispatch::Static. https://github.com/rails/rails/commit/52260581638406d910e09e8d2e66b51acb76c5c6Maintain in test.rb
config.assets.debug = true
- disables concatenation and preprocessing of assetsconfig.consider_all_requests_local = true
- when set to true then any error will cause detailed debugging information to be dumped in the HTTP response, and the Rails::Info controller will show the application runtime context in /rails/info/properties.config.action_controller.perform_caching = true
- enables caching in test environment.config.action_mailer.default_url_options = { host: 'localhost:3000' }
- set default host that will be used for mailers in test environment.Delete in test.rb
config.action_controller.include_all_helpers = true
- In Rails 5 the default configuration behavior (when this option is not explicitly set to true or false) is that all view helpers are available to each controller.config.active_record.raise_in_transactional_callbacks = true
- Active Record no longer suppresses errors raised within after_rollback or after_commit callbacks in Rails 5. Hence I don't think this line is needed.boot.rb
Rails 5 uses
require 'bundler/setup'
without checkingif File.exist?(ENV['BUNDLE_GEMFILE'])
. The if check was causing Gemfile related errors. https://github.com/rails/rails/pull/16046config/initializers/cookies_serializer.rb
Replace
Nextrequest::Application.config.session_store :cookie_store, key: '_recordquest_session'
withRails.application.config.session_store :cookie_store, key: '_nextrequest_session'
- the code specifies what class to use to store the session.initializers/wrap_parameters.rb
Replace
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
withwrap_parameters format: [:json]
- as checking if controller responds to wrap_parameter is not longer required. Keep the rest of the code as is.initializers/mime_types.rb
Delete
# Mime::Type.register_alias "text/html", :iphone
- Rails 5 takes out this line so as not to encourage the use of aliases.locales/en.yml
Keep as is. Local changes were made to this file for testing and error handling purposes.
Rakefile
Update
require File.expand_path("../config/application", __FILE__)
withrequire_relative "config/application"
andNextrequest::Application.load_tasks
withRails.application.load_tasks
and keep the code below, which was added to added rerun rspec to cut down on failing testsNew files that Rails 5 ships with
assets/config/manifest.js
- tells Sprockets which files to require in order to build a single CSS or JavaScript file. Previously you didn’t need to include fonts and images in your precompiled assets list. Link your JS and CSS directories as well as any other directories like images, fonts, sounds etc inside this file. http://eileencodes.com/posts/the-sprockets-4-manifest/assets/javascripts/cable.js
- Added for Action Cablechannels/application_cable/channel.rb
- Added for Action Cable. Used to place shared logic between channels.app/jobs/application_job.rb
- the jobs folder was previously created whenever a new job was created, but now it exists by default.application_job.rb
is a global file from which jobs inherit.app/mailers/application_mailer.rb
- Mailers inherit from ApplicationMailer in Rails 5.layouts/mailer.html.erb
- Added for ActionMailerlayouts/mailer.text.erb
- Added for ActionMailerapp/models/application_record.rb
- ApplicationRecord is a new superclass for all app models, analogous to app controllers subclassing. This provides a single point of entry for customizations and extensions needed for an application. It prevents the need for monkey patching ActiveRecord::Base when we want to add extra functionality to Active Record. https://blog.bigbinary.com/2015/12/28/application-record-in-rails-5.htmlbin/update
- Adds the ability to run tasks and tests through bin/rails instead of rake. Run Runbin/rails
to see the list of commands available.config/cable.yml
- contains settings for Action Cable.config/initializers/new_framework_defaults.rb
- contains settings used for backwards compatibility. https://blog.bigbinary.com/2016/08/18/new-framework-defaults-in-rails-5-to-make-upgrade-easier.htmlconfig/puma.rb
- Puma is now the default development web serverconfig/spring.rb
- Spring is a Rails application preloader. It speeds up development by keeping the application running in the background so it does't have to be booted every time a test, a rake task or migration is run.Config files removed in Rails 5
config/initializers/to_time_preserves_timezone.rb
-ActiveSupport.to_time_preserves_timezone = false
is instead set innew_framework_defaults.rb
. Set this to true in order to preserve the timezone of the receiver.Rails 5 Readme comes in markdown format instead of rdoc.
Additional Features
Rails 5 brings consistency by wrapping all rake commands using rails https://blog.bigbinary.com/2016/01/14/rails-5-supports-rake-commands-using-rails.html
Rails 5 Diff
config.assets.precompile
andconfig.assets.version
to config/initializers/assets.rb [ ] In config/environments/production.rb add config.log_level = :debug [ ] Check if config.log_tags = [ :subdomain, :uuid ] was an internal change and if it is still needed. [ ] In Precompile additional assets - check what the assets file has [ ] In config/environments/production.rb check if disable automatic flushing of the log to improve performance is still needed (config.autoflush_log = false) [ ] Keep the lograge that is currently there and add the comments. [ ] Check if config.action_controller.include_all_helpers = true should be deleted from config/environments/production.rb, test.rb, development.rb [ ] For config/test go through the above steps [ ] In mime_types.rb check if Mime::Type.register_alias was added internally and whether it is still supported [ ] In session_store.rb, see what the change in accomplishes (Nextrequest vs Rails) [ ] In wrap_parameters.rb check to see ifwrap_parameters format: [:json] if respond_to?(:wrap_parameters)
was added internally and if it is still needed*[ ] In /bin/rails
APP_PATH = File.expand_path('../config/application', __dir__)
check what the change with FILE accomplishes.