Sha256: 107520bb88c22255b858b0b59e4e6a0eb9fa710d6649ea9c1b2c486000cbb286

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

require_dependency 'landable/has_assets'

module Landable
  class Theme < ActiveRecord::Base
    include Landable::TableName
    include Landable::HasAssets
    include Landable::Librarian

    validates_presence_of :name, :description
    validates_uniqueness_of :name, case_sensitive: false

    has_many :pages, inverse_of: :theme

    class << self
      def create_from_layouts!
        return unless table_exists?
        Layout.all.map(&:to_theme)
      end

      def most_used_on_pages
        order('pages_count DESC').first
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 app/models/landable/theme.rb
landable-1.13.2 app/models/landable/theme.rb