adbanner-test/config/routes.rb

32 lines
929 B
Ruby

Rails.application.routes.draw do
require 'fileutils'
get 'ad_banners/widget'
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
Thread.new do
s = Site.first
update_flag = s.respond_to?(:tmp_flags)
need_update = !update_flag || !(s.tmp_flags.include?('adf1'))
if need_update
ad_images = AdImage.where(:video_file.ne=>nil,:video_snapshot=>nil).to_a
ad_images.each do |ad_image|
ad_image.generate_video_snapshot
end
if update_flag
Site.update_all("$push"=>{"tmp_flags"=>'adf1'})
end
end
end
end
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
post "/ad_banner/save_image_order", to: "ad_banners#save_image_order"
resources :ad_banners
resources :ad_images
end
end
end