将Rails 5与Google :: Apis :: DriveV2一起使用,我试图重命名文件:
在gem文件中,我有google-api-client和Devise
gem 'google-api-client'
gem 'devise
我像这样配置Drive服务(在初始化文件中):
Drive = Google::Apis::DriveV2::DriveService.new
在我的控制器内,我做
file = Drive.copy_file("id_of_the_template")
# first try to rename
Drive.patch_file(file.id,"body"=>{"title"=>"New_Name"})
# second try to rename
project_slide.title = "New_Name"
project_slide.update!
该文件完全重复,但第一次和第二次尝试都没有重命名该文件。
以前我试过:
Drive.patch_file(file.id,"body"=>{"title"=>"New_Name"})
我收到了这个错误
NoMethodError (undefined method `rename' for #<Google::Apis::DriveV2::File:0x007f9e06809fe8>):
我花了好几个小时寻找一种有效的方法但却找不到它,而且我在Google文档中迷失了方向。 这里是我读过的文档: