Class: Site

Inherits:
ApplicationRecord show all
Includes:
BaseModel, SoftDelete
Defined in:
app/models/site.rb

Instance Method Summary collapse

Methods included from SoftDelete

#deleted?, #destroy

Methods included from BaseModel

#pull, #push

Instance Method Details

#favicon_urlObject


26
27
28
29
30
# File 'app/models/site.rb', line 26

def favicon_url
  return '' if url.blank?
  domain = url.gsub('http://', '')
  "https://favicon.b0.upaiyun.com/ip2/#{domain}.ico"
end

#fix_urlsObject


19
20
21
22
23
24
# File 'app/models/site.rb', line 19

def fix_urls
  unless url.blank?
    url = self.url.gsub(%r{http[s]{0,1}://}, '').split('/').join('/')
    self.url = "http://#{url}"
  end
end

#update_cache_versionObject


13
14
15
16
# File 'app/models/site.rb', line 13

def update_cache_version
  # 记录节点变更时间,用于清除缓存
  CacheVersion.sites_updated_at = Time.now.to_i
end