FEATURE: New 'Reviewable' model to make reviewable items generic

Includes support for flags, reviewable users and queued posts, with REST API
backwards compatibility.

Co-Authored-By: romanrizzi <romanalejandro@gmail.com>
Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
This commit is contained in:
Robin Ward
2019-01-03 12:03:01 -05:00
parent 9a56b398a1
commit b58867b6e9
354 changed files with 8090 additions and 5225 deletions

View File

@@ -2,6 +2,7 @@
# child objects with errors
module HasErrors
attr_reader :errors
attr_accessor :forbidden, :not_found, :conflict
def errors
@errors ||= ActiveModel::Errors.new(self)
@@ -23,10 +24,18 @@ module HasErrors
raise ActiveRecord::Rollback.new
end
def add_error(msg)
errors[:base] << msg unless errors[:base].include?(msg)
end
def add_errors_from(obj)
obj.errors.full_messages.each do |msg|
errors[:base] << msg unless errors[:base].include?(msg)
return if obj.blank?
if obj.is_a?(StandardError)
return add_error(obj.message)
end
obj.errors.full_messages.each { |msg| add_error(msg) }
end
end