我正在尝试使用 activerecord 导入进行导入。我收到无效参数错误我该如何解决这个问题?
谢谢
我在 postgresql 中的表架构:
create_table "vehicle_locations", force: :cascade do |t|
t.string "plate"
t.datetime "timestamp"
t.float "latitude"
t.float "longitude"
t.integer "speed"
t.integer "mileage"
t.boolean "ignition_on"
t.string "address"
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下代码导入:
values = [{"plate":"xxx","timestamp":"2017-11-28
20:42:57","latitude":41.9322,"longitude":27.3253,"speed":0,"mileage":1984
04,"ignition_on":true,"address":"address"},{"plate":"xxx","timestamp":"2017-11-28 20:43:46","latitude":47.0148,"longitude":39.1805,"speed":16,"mileage":209726,"ignition_on":true,"address":"address"}]
columns = [:plate, :timestamp, :latitude, :longitude, :speed, :mileage, :ignition_on, :address ]
VehicleLocation.import columns, values
Run Code Online (Sandbox Code Playgroud)
我正在使用 postgresql、rails 5.1。
提前致谢。
2017-11-28T17:45:08.844Z 17976 TID-gn4tnwlkc WARN: ArgumentError: Invalid arguments!
2017-11-28T17:45:08.844Z 17976 TID-gn4tnwlkc WARN: /home/kayayan/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-import-0.21.0/lib/activerecord-import/import.rb:508:in `import_helper'
/home/kayayan/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-import-0.21.0/lib/activerecord-import/import.rb:399:in `import'
/home/kayayan/Projects/RoR/trasportapp/app/workers/trio_worker.rb:23:in `perform'
/home/kayayan/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:188:in `execute_job'
/home/kayayan/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:170:in `block (2 levels) in process' …Run Code Online (Sandbox Code Playgroud) 我正在使用microsoft anti xss库来形成安全性.我正在使用HtmlFormUrlEncode方法.
如何解码录制的数据?
样本数据 :
mail%40sample.com
%c3%96nder
Run Code Online (Sandbox Code Playgroud) 我试图在C++中连接两个字符串:
"G1-2" + "-%02d.jpg"
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
G1-2-1537817269.jpg
Run Code Online (Sandbox Code Playgroud)
为什么不是这样的结果: "G1-2-%02d.jpg"