cartodb/app/models/carto/user_notification.rb

22 lines
549 B
Ruby
Raw Normal View History

2020-06-15 10:58:47 +08:00
require_relative './carto_json_serializer'
module Carto
class UserNotification < ActiveRecord::Base
belongs_to :user
serialize :notifications, ::Carto::CartoJsonSymbolizerSerializer
validates :user, presence: true
validate :only_valid_categories
VALID_CATEGORIES = [:builder, :dashboard].freeze
private
def only_valid_categories
notifications.keys.none? do |category|
errors.add(:notifications, "Invalid category: #{category}") unless VALID_CATEGORIES.include?(category)
end
end
end
end