-
Notifications
You must be signed in to change notification settings - Fork 109
Upgrading from v3.x to v4.x
Brian Riley edited this page Oct 24, 2022
·
1 revision
DMPRoadmap v4.x is a major upgrade that brings the system up to Rails 6.1 and Ruby 2.7. Please review the following information as it may impact your local customizations.
The following is a list of configuration changes you will need to make to your local installations to support Rails 6+:
- New environment variable called
DMPROADMAP_HOST
. Rails 6+ introduces new middleware that helps mitigate DNS rebinding attacks. This includes a hostname whitelist. The whitelist includes localhost for the development environment, but does not include anything in other environments. Setexport DMPROADMAP_HOST=my.example.org
appropriately for each environment. If you have other hostnames you need to support, you can adjust theconfig/application.rb
file to include them. - We needed to reconfigure the
config/translation.rb
so that it does not reference Rails framework elements that have not yet been defined. Please review this file and adjust theSUPPORTED_LOCALES, CLIENT_LOCALES and DEFAULT_LOCALE
constants at the top as needed.
The following issues have been addressed as part of the Ruby and Rails upgrades. You should inspect your instances customizations to determine if you will need to make similar adjustments.
- The ActiveModel
update_attributes
method has been deprecated. Useupdate
instead. -
serialize
must be called after the attribute definition in ActiveModel. For exampleserialize :my_attr, JSON; attribute :my_attr, :text, default: 'foo'
will return a text string instead of parsed JSON. To correct this, just flip the order so thatserialize
is called last - You should use the
record.errors.add(attribute, message)
method for ActiveRecord errors instead ofrecord.errors[attribute] << message
format - Introduction of Zeitwerk which is used to handle Rails' convention over configuration tooling. It is stricter than the classic version so your naming conventions must adhere to Rails standards:
- Camel case module and class names only. For example
JsonLinkValidator
instead ofJSONLinkValidator
- file names and directory structures must match module/class definitions. For example
app/controllers/contacts_controller.rb
withmodule ContactUs; class ContactsController < ApplicationController
is invalid. The directory structure should beapp/controllers/contact_us/contacts_controller.rb
. You can runrails zeitwerk:check
to help find any issues.
- Camel case module and class names only. For example
- Attempting to access Rails objects that are typically only available after the application has initialized within an initializer is invalid. For example, we can no longer reference DB tables like
Language.all
in theconfig/translation.rb
because Zeitwerk will attempt to auto-load objects that have not yet been defined.
- Home
- About
- Development roadmap
- Releases
- Themes
- Google Analytics
- Get involved
- Translations
- Developer guide