cartodb-4.42/app/models/carto/user_notification.rb

22 lines
549 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +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