gpt4 book ai didi

ruby-on-rails-4 - Skydrive 重命名文件夹

转载 作者:行者123 更新时间:2023-12-03 17:43:04 25 4
gpt4 key购买 nike

我在 Rails 应用程序中使用 Skydrive gem。

为了重命名我写的文件夹

def renaming_folder
client = Skydrive::Client.new(@@access_token)
folder_id = params[:folder_id]
# (url, {:body => options})
# options = {name: "#{params[:rename_field]}"}
puts "-------------------..."
puts "#{params[:folder_id]}"
client.get_skydrive_object_by_id(folder_id)

# I believe issue comes from this line:
folderObject = client.update_skydrive_object("#{params[:folder_id]}", options={name: "#{params[:rename_field]}"})

redirect_to drive_show_path
end

但我收到 http_error_400: Bad Request 错误。我正进入(状态
{"utf8"=>"✓",
"authenticity_token"=>"BAYGFcb5/74c7RV5NH1u4DCAT1MqLvLCkp9F3Q/Fav+B2wdab4aE5LBJAVr90MMu0GbfFwHTuLyncFRWtGyYTA==",
"rename_field"=>"weqweqwe",
"folder_id"=>"folder.cecb8eb83d90dbeb.CECB8EB83D90DBEB!106",
"commit"=>"Rename Folder"}

在我的参数中。

有人可以帮忙吗?寻找来自可靠和/或官方来源的答案。

添加看跌期权时,我能够获得所有值。

最佳答案

HTTP 400 错误意味着服务器无法理解您的 HTTP 请求:http://pcsupport.about.com/od/findbyerrormessage/a/400error.htm .
"#{params[:folder_id]}""#{params[:rename_field]}"是不必要的方式只是说 params[:folder_id]params[:rename_field] ,它们已经是字符串。

client.get_skydrive_object_by_id(folder_id).update(options={name: params[:rename_field] .

您的解决方案应该是:
skydrive_folder = client.get_skydrive_object_by_id(folder_id)
skydrive_folder.update(options = {name: params[:rename_field]})

供引用:http://www.rubydoc.info/gems/skydrive/1.2.0/Skydrive/Operations#update_skydrive_object-instance_method
http://www.rubydoc.info/gems/skydrive/Skydrive/Folder#update-instance_method

源代码:

第 119 行:https://github.com/ronyv89/skydrive/blob/master/lib/skydrive/operations.rb

第 44 行:https://github.com/ronyv89/skydrive/blob/master/lib/skydrive/client.rb

关于ruby-on-rails-4 - Skydrive 重命名文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com