Sha256: f63a03fb21eb5c864bd584d6c40051f0ba811ee45172c695f46a994793d12a53

Contents?: true

Size: 458 Bytes

Versions: 16

Compression:

Stored size: 458 Bytes

Contents

module Landable
  class Category < ActiveRecord::Base
    include Landable::TableName

    has_many :pages

    validates_uniqueness_of :name, case_sensitive: false
    validates_uniqueness_of :slug

    before_validation :set_slug

    def to_liquid
      {
        'name' => name,
        'pages' => pages.published,
      }
    end


    protected

    def set_slug
      self.slug = name.downcase.gsub(/[^\w]/, '_').gsub(/_{2,}/, '_')
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 app/models/landable/category.rb
landable-1.12.3 app/models/landable/category.rb
landable-1.12.2 app/models/landable/category.rb
landable-1.12.1 app/models/landable/category.rb
landable-1.11.1 app/models/landable/category.rb
landable-1.11.0 app/models/landable/category.rb
landable-1.10.0.rc2 app/models/landable/category.rb
landable-1.10.0.rc1 app/models/landable/category.rb
landable-1.9.2 app/models/landable/category.rb
landable-1.9.1 app/models/landable/category.rb
landable-1.9.0 app/models/landable/category.rb
landable-1.9.0.rc2 app/models/landable/category.rb
landable-1.9.0.rc1 app/models/landable/category.rb
landable-1.8.0 app/models/landable/category.rb
landable-1.7.1.rc1 app/models/landable/category.rb
landable-1.7.0 app/models/landable/category.rb