fix error
This commit is contained in:
parent
38e130664e
commit
430c673fdf
|
@ -22,11 +22,11 @@ class SiteFeed
|
|||
end
|
||||
end
|
||||
before_destroy do
|
||||
tmp = SiteFeedAnnc.where(feed_id: self.id).first
|
||||
tmp = SiteFeedAnnc.where(feed_id: self.id)
|
||||
main_directory = File.join("#{Rails.root}","public","site_feeds")
|
||||
feed_directory = File.join(main_directory.to_s, self.id.to_s)
|
||||
FileUtils.rm_rf(feed_directory.to_s)
|
||||
if !tmp.nil?
|
||||
if tmp.count!=0
|
||||
tmp.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,10 @@ Rails.application.routes.draw do
|
|||
end
|
||||
SiteFeedAnnc.where(:feed_id.nin=>SiteFeed.all.pluck(:id)).destroy
|
||||
SiteFeed.each do |site_feed|
|
||||
count = SiteFeedAnnc.where(feed_id: site_feed.id).count
|
||||
if count>1
|
||||
SiteFeedAnnc.where(feed_id: site_feed.id).limit(count-1).destroy
|
||||
end
|
||||
tmp = SiteFeedAnnc.where(feed_id: site_feed.id).first
|
||||
if site_feed.disabled != true
|
||||
if tmp.nil?
|
||||
|
|
|
@ -7,6 +7,10 @@ module FeedModel
|
|||
before_save :do_before_save
|
||||
end
|
||||
def recreate_annc_cache(feed)
|
||||
count = SiteFeedAnnc.where(feed_id: feed.id).count
|
||||
if count>1
|
||||
SiteFeedAnnc.where(feed_id: feed.id).limit(count-1).destroy
|
||||
end
|
||||
tmp = SiteFeedAnnc.where(feed_id: feed.id).first
|
||||
if tmp.nil?
|
||||
tmp = SiteFeedAnnc.new(feed_id: feed.id)
|
||||
|
|
Loading…
Reference in New Issue