-
Couldn't load subscription status.
- Fork 118
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.orgappropriately for each environment. If you have other hostnames you need to support, you can adjust theconfig/application.rbfile to include them. - We needed to reconfigure the
config/translation.rbso 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_LOCALEconstants 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_attributesmethod has been deprecated. Useupdateinstead. -
serializemust 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 thatserializeis called last - You should use the
record.errors.add(attribute, message)method for ActiveRecord errors instead ofrecord.errors[attribute] << messageformat - 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
JsonLinkValidatorinstead ofJSONLinkValidator - file names and directory structures must match module/class definitions. For example
app/controllers/contacts_controller.rbwithmodule ContactUs; class ContactsController < ApplicationControlleris invalid. The directory structure should beapp/controllers/contact_us/contacts_controller.rb. You can runrails zeitwerk:checkto 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.allin theconfig/translation.rbbecause Zeitwerk will attempt to auto-load objects that have not yet been defined.
- Home
- About
- Contributing
- Releases
- Themes
- Google Analytics
- Translations
- Developer guide
- Reporting Issues

