Sha256: 13c7df72352fe51660f258fb65832828fc7bd98bade264b2daebffe399d25ebc

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

require 'babosa'

module C80Yax
  class Cat < ActiveRecord::Base

    validates :title,
              presence: true,
              uniqueness: true,
              length: { in: 6..50 }

    has_and_belongs_to_many :strsubcats
    mount_uploader :image, IcatUploader

    extend FriendlyId
    friendly_id :slug_candidates, :use => :slugged

    def slug_candidates
      [:title] + Array.new(6) {|index| [:title, index+2]}
    end

    def normalize_friendly_id(input)
      input.to_s.to_slug.normalize(transliterations: :russian).to_s
    end

    scope :menu_order, -> {order(:ord => :asc)}

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
c80_yax-0.1.0.4 app/models/c80_yax/cat.rb