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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.