activestorage-validator icon indicating copy to clipboard operation
activestorage-validator copied to clipboard

Non-ActiveRecord object

Open helphop opened this issue 6 years ago • 4 comments

helphop avatar Feb 05 '19 08:02 helphop

I am using the validator in a form object class as follows:

class QuoteRequestForm
  include ActiveModel::Model
  include NullObject::Conversions

  attr_accessor :name, :email, :time_zone, :file

  validates :file, presence: true, blob: { content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }

end

However, the tests fail as follows:

ArgumentError:
  Unknown validator: 'BlobValidator'

helphop avatar Feb 05 '19 08:02 helphop

I think you need to include the ActiveRecord::Validations Because the BlobValidator class is defined inside that module.

DeadlockDruid avatar Feb 26 '19 15:02 DeadlockDruid

Same issue here - that include doesn't work

aximuseng avatar Jul 30 '19 14:07 aximuseng

It's difficult because activestorage is closely related to activerecord.

aki77 avatar Sep 02 '19 10:09 aki77