Skip to content

Migrate from Virtus to ActiveModel::Attributes API #8514

@andreslucena

Description

@andreslucena

Is your feature request related to a problem? Please describe.

Currently Decidim relies heavily on the Virtus gem for the attribute assignment and type coercion for form inputs from the end user. The Virtus gem has been officially discontinued since 2019 and the maintainer has reported to have stopped working on the gem since 2015. The Virtus repository has had some recent maintenance activity from the maintainer but the gem itself is no longer actively developed.

Describe the solution you'd like

To use ActiveModel::Attributes which ships with Rails.

Describe alternatives you've considered

Dry-rb, but it seems like ActiveModel::Attributes was more promising, and also is the native and official solution for this problem.

Additional context

See the discussion at #7234. As a summary:

Alternatives were investigated and it was suggested by @ahukkanen that we could replace the Virtus gem by Decidim’s own layer that is based on ActiveModel::Attributes which ships with Rails. This seemed to be possible to do during a proof of concept work which showed that at least the decidim-core gem’s forms were possible to make compatible with the new layer as shown by the decidim- core gem’s RSpec test suite. This proof of concept did not require any changes to the existing form classes maintaining a fully backwards compatible API. Further work is necessary to make everything work that Decidim uses from Virtus.

This refactoring effort will also allow Decidim to reduce the dependency on the following low maintenance gems that are currently core depdendencies through Virtus:

  • virtus-multiparams
  • coersible
  • descendants_tracker

It should be noted that two of these gems (coersible, descendants_tracker) will still remain in the Decidim Gemfile.lock but they won’t be used anywhere in Decidim applications after this refactoring effort. They are still dependencies for Rectify that is still used for commands, queries and presenters as well as axe-core that is still used for the RSpec test suite to run accessibility violations during the CI.

Does this issue could impact on users private data?

It should't change anything about the behaviour of PII, as this is a refactor.

Funded by

Decidim Association


Note: this issue definition was largely made by @ahukkanen, that explains it all really well IMHO!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions