Sha256: 7af52d042c44a97542f37aa8d47328aec9db8a99a720fda1cfe450eb79d6fe4a
Contents?: true
Size: 1.83 KB
Versions: 3
Compression:
Stored size: 1.83 KB
Contents
require 'babosa' include ActionView::Helpers::SanitizeHelper module Ti class Doc < ActiveRecord::Base has_many :dphotos, :dependent => :destroy accepts_nested_attributes_for :dphotos, :reject_if => lambda { |attributes| !attributes.present? }, :allow_destroy => true has_and_belongs_to_many :categories has_and_belongs_to_many :items, class_name: 'C80Yax::Item', foreign_key: 'item_id', join_table: 'ti_docs_items', association_foreign_key: 'doc_id' validates_with DocValidator default_scope {order(:created_at => :desc)} extend FriendlyId friendly_id :title, use: :slugged def normalize_friendly_id(input) input.to_s.to_slug.normalize(transliterations: :russian).to_s end def slug_candidates [:title] + Array.new(6) {|index| [:title, index+2]} end def short_meta_description if description.present? && description.length > 200 result = description elsif full.present? && full.length > 0 result = strip_tags(full[0..200]+'...') else result = nil end result end def thumb_sm s = '' if dphotos.count > 0 s = dphotos.first.image.thumb_sm end s end def thumb_md s = '' if dphotos.count > 0 s = dphotos.first.image.thumb_md end s end def thumb_lg s = '' if dphotos.count > 0 s = dphotos.first.image.thumb_lg end s end def thumb_preview s = '' if dphotos.count > 0 s = dphotos.first.image.thumb_preview end s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
c80_yax-0.1.0.25 | engines/ti/app/models/ti/doc.rb |
c80_yax-0.1.0.24 | engines/ti/app/models/ti/doc.rb |
c80_yax-0.1.0.23 | engines/ti/app/models/ti/doc.rb |