Sha256: b4470df2a2fc3428bc0a4a06b5861bc2e5a9b1226f88d200f3c50500b668adb2

Contents?: true

Size: 800 Bytes

Versions: 9

Compression:

Stored size: 800 Bytes

Contents

class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
  enumerize :block_type, in: [ :header, :footer, :page, :cards, :features, :contacts, :news ]
  enumerize :navbar_link, in: [ :exist, :not_exist ], default: :not_exist

  mount_uploader :background, PhotoUploader

  state_machine :view_state, initial: :published do
    state :published
    state :hidden

    event :publish do
      transition hidden: :published
    end

    event :hide do
      transition published: :hidden
    end
  end

  scope :on_main_page, -> { active.where(view_state: :published).order :position }
  scope :with_navbar_link, -> { where navbar_link: :exist }
  scope :header, -> { on_main_page.where(block_type: :header).first }
  scope :footer, -> { on_main_page.where(block_type: :footer).first }
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tramway-landing-1.1.3.1 app/models/tramway/landing/block.rb
tramway-landing-1.1.3.trash.pre.3 app/models/tramway/landing/block.rb
tramway-landing-1.1.3.trash.pre.2 app/models/tramway/landing/block.rb
tramway-landing-1.1.3.trash app/models/tramway/landing/block.rb
tramway-landing-1.1.3 app/models/tramway/landing/block.rb
tramway-landing-1.1.2 app/models/tramway/landing/block.rb
tramway-landing-1.1.1 app/models/tramway/landing/block.rb
tramway-landing-1.1 app/models/tramway/landing/block.rb
tramway-landing-1.0 app/models/tramway/landing/block.rb