2013-04-10 07:26:57 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
namespace :web_link_url do
|
|
|
|
task :web_link_url_i18n => :environment do
|
|
|
|
|
|
|
|
puts 'start'
|
|
|
|
|
|
|
|
@weblinks = WebLink.all
|
|
|
|
|
|
|
|
@weblinks.each do |wl|
|
|
|
|
|
2013-06-10 07:52:11 +00:00
|
|
|
if wl.url_translations.is_a?(String)
|
|
|
|
|
|
|
|
@wlurl = wl.url_translations
|
|
|
|
|
|
|
|
wl.url_translations = {}
|
|
|
|
|
|
|
|
wl.url_translations["zh_tw"] = @wlurl
|
|
|
|
|
|
|
|
wl.url_translations["en"] = @wlurl
|
|
|
|
|
|
|
|
wl.save
|
2013-04-10 07:26:57 +00:00
|
|
|
|
|
|
|
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
|