2015-07-10 190 views
5

我在我的rails應用程序中使用Skydrive gem。Skydrive重命名文件夾

重命名我寫

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的文件夾:錯誤的請求錯誤。我越來越

{"utf8"=>"✓", 
"authenticity_token"=>"BAYGFcb5/74c7RV5NH1u4DCAT1MqLvLCkp9F3Q/Fav+B2wdab4aE5LBJAVr90MMu0GbfFwHTuLyncFRWtGyYTA==", 
"rename_field"=>"weqweqwe", 
"folder_id"=>"folder.cecb8eb83d90dbeb.CECB8EB83D90DBEB!106", 
"commit"=>"Rename Folder"} 

在我的參數。

有些人可以幫忙嗎?尋找來自可信和/或官方消息來源的答案。

我可以在添加放入時獲得所有的值。

回答

0

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_methodhttp://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

+0

已更改skydrive_object = client.get_skydrive_object_by_id(folder_id)skydrive_object.update_skydrive_object(params [:folder_id],options = {name:params [:rename_field]}),但它給NoMethodError:未定義的方法'update_skydrive_object'爲#錯誤 – Neha

+0

還檢查了選項folderObject = client.update_skydrive_object(「#{params [:folder_id]}」,options = {})中的空白值,然後它給出Skydrive :: Error(http_error_400:Bad Request) – Neha

+0

如果你有任何其他選項,請讓我知道。 – Neha