cartodb-4.42/app/models/carto/user_notification.rb
2024-04-06 05:25:13 +00:00

22 lines
549 B
Ruby

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