52 lines
777 B
Ruby
52 lines
777 B
Ruby
# encoding: utf-8
|
|
|
|
namespace :web_link_url do
|
|
task :web_link_url_i18n => :environment do
|
|
|
|
puts 'start'
|
|
|
|
@weblinks = WebLink.all
|
|
|
|
@weblinks.each do |wl|
|
|
|
|
if wl.url.nil?
|
|
|
|
@wlurl = wl.url_translations
|
|
|
|
wl.url_translations = {}
|
|
|
|
wl.url_translations["zh_tw"] = @wlurl
|
|
|
|
wl.url_translations["en"] = @wlurl
|
|
|
|
wl.save
|
|
|
|
else
|
|
puts 'no data'
|
|
end
|
|
|
|
end
|
|
|
|
puts 'end'
|
|
|
|
puts @weblinks.count
|
|
|
|
end
|
|
|
|
task :web_link_url_i18n_test => :environment do
|
|
|
|
@test = WebLink.find("50aca25583e75204c00009f4")
|
|
|
|
@testurl = @test.url_translations
|
|
|
|
@test.url_translations = {}
|
|
|
|
@test.url_translations["zh_tw"] = @testurl
|
|
|
|
@test.url_translations["en"] = @testurl
|
|
|
|
@test.save
|
|
|
|
end
|
|
|
|
end |