Sha256: a837f5d54669c266c5b701579b5d7757e10fc3ac41e9870e8d589deacdc342d2
Contents?: true
Size: 463 Bytes
Versions: 1
Compression:
Stored size: 463 Bytes
Contents
class Spree::UserDevice < ApplicationRecord belongs_to :device belongs_to :user validates :user, presence: true validates_associated :device validate :device_limit private def device_limit return if user.blank? return unless new_record? max_number_of_devices = SpreeDevices.config.try(:max_number_of_devices) || 3 errors.add(:device, I18n.t('errors.device_limit_reached')) if user.devices.count >= max_number_of_devices end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_devices-1.2.0 | app/models/spree/user_device.rb |