Sha256: e9ced46595e11ca5e6191690f02bd9f9be169addc75b964cfe53fe6f7986cffe
Contents?: true
Size: 475 Bytes
Versions: 20
Compression:
Stored size: 475 Bytes
Contents
# If you want to use this concern, you need to add a boolean field 'visible' to # the model. module Concerns module Visible extend ActiveSupport::Concern included do scope :visible, ->{ where(visible: true) } scope :hidden, ->{ where('visible = 0 OR visible IS NULL') } end def hidden? !visible? end def hide! update_attribute :visible, false end def show! update_attribute :visible, true end end end
Version data entries
20 entries across 20 versions & 1 rubygems