Class: Redde::Seo

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/redde/seo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#skip_basic_validationObject

Returns the value of attribute skip_basic_validation.



5
6
7
# File 'app/models/redde/seo.rb', line 5

def skip_basic_validation
  @skip_basic_validation
end

Class Method Details

.categoriesObject



29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/redde/seo.rb', line 29

def self.categories
  self.select('seos.seoable_type, COUNT(*) AS type_count').group('seos.seoable_type')
    .inject({}) do |res, t|
      if t.seoable_type
        name = "#{t.seoable_type.constantize.model_name.human} (#{t.type_count})"
      else
        name = "Без привязки (#{t.type_count})"
      end
      res.merge(name => t.seoable_type)
  end
end

.for_empty(empty = nil) ⇒ Object



41
42
43
44
45
# File 'app/models/redde/seo.rb', line 41

def self.for_empty(empty = nil)
  return self.all if empty.nil?
  return self.empty if empty == 'true'
  self.full
end

.model_nameObject



25
26
27
# File 'app/models/redde/seo.rb', line 25

def self.model_name
  ActiveModel::Name.new(self, nil, 'Seo')
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/redde/seo.rb', line 21

def empty?
  !(title.present? && keywords.present? && description.present?)
end