0

I am trying out Reform using the reform-rails gem for the first time. I am trying to use it as a form object, do some validation and then persist it to the database. When I try to specify a validation it gives an error even when I try one of its own examples.

Gemfile:

gem 'reform'
gem 'reform-rails'
gem 'dry-validation'

config/initializerrs/reform.rb

require 'reform/form/dry'

Reform::Form.class_eval do
  feature Reform::Form::Dry
end

Rails.application.config.reform.validations = :dry

app/forms/album_form.rb:

class AlbumForm < Reform::Form
  feature Reform::Form::Dry

  property :name

  validation do
    required(:name).filled
  end

  property :artist do
    property :name

    validation do
      required(:name).filled
    end
  end
end

Command line:

AlbumForm.new(Album.new)
Traceback (most recent call last):
        3: from (irb):1:in `<main>'
        2: from app/forms/album_form.rb:1:in `<main>'
        1: from app/forms/album_form.rb:6:in `<class:AlbumForm>'
ArgumentError (wrong number of arguments (given 1, expected 0))

Line 6 is validation do. Am I missing some thing?

Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71

1 Answers1

0

As of today, Reform (and Reform Rails) doesn't support Ruby 3. The update appears to be close for a release. All but one test passes. The test that fails appear to be related to Representable gem.

This is according to Yogesh Khater from the Trailblazer - Reform thread at the Zulip Chat

Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71