patch rails validation
Added by Dmitry Shtolz almost 4 years ago
how to patch AR validation correctly?
model Issue validates_length_of :subject, :maximum => 255
my code
module IssuesPatch def self.included(base) base.class_eval do validates_length_of :subject, :maximum => 1_000 end end end Rails.configuration.after_initialize do require_dependency 'issue' Issue.send(:include, IssuesPatch) end
after Issue.create(subject: "Long string...").errors:
:subject=>["is too long (maximum is 255 characters)", "is too long (maximum is 1000 characters)"]}
as far as I understand, you need to remove the old validation? or patch it?
how to do it?
Redmine version 4.1.1.stable
Ruby version 2.6.6-p146 (2020-03-31) [x64-mingw32]
Rails version 5.2.4.2