mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 10:05:24 +08:00
1be01f8dd4
Minor fixes to add Rails 6 support to Discourse, we now will boot with RAILS_MASTER=1, all specs pass Only one tiny deprecation left Largest change was the way ActiveModel:Errors changed interface a bit but there is a simple backwards compat way of working it
16 lines
382 B
Ruby
16 lines
382 B
Ruby
class UploadUrlValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
if value.present?
|
|
uri =
|
|
begin
|
|
URI.parse(value)
|
|
rescue URI::Error
|
|
end
|
|
|
|
unless uri && Upload.exists?(url: value)
|
|
record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
|
|
end
|
|
end
|
|
end
|
|
end
|