count-anything/app/models/total.rb
Louis Vallat d07857c011
feat: added counts and instant update and destroy
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-02-05 21:01:07 +01:00

31 lines
599 B
Ruby

# == Schema Information
#
# Table name: totals
#
# id :integer not null, primary key
# count :integer default(0), not null
# name :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_totals_on_name (name)
#
class Total < ApplicationRecord
validates_uniqueness_of :name
validates_length_of :name, in: 1..32
after_save do
CountChannel.create(self)
end
after_update do
CountChannel.update(self)
end
after_destroy do
CountChannel.destroy(self)
end
end