Sha256: a31ace466b169eac2af8c0e47525e37881403b10bff3bd5dc098a129136c48bf
Contents?: true
Size: 477 Bytes
Versions: 52
Compression:
Stored size: 477 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
52 entries across 52 versions & 1 rubygems