如何使用google_drive gem解决NoMethodError?

时间:2015-03-10 20:45:22

标签: ruby-on-rails google-drive-api

我正在尝试创建一个从我的google云端硬盘中的电子表格中读取的网络应用。但当我完成Oauth2程序并想要列出文件时,我得到了这个错误:

NoMethodError: undefined method `drive' for nil:NilClass
    from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:101:in `drive'
    from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:149:in `file_by_id'
    from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:186:in `spreadsheet_by_key'
    from (irb):21
    from /Users/administrator/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'

我使用Rails 4.2.0和ruby 2.2.0

1 个答案:

答案 0 :(得分:1)

client_or_access_token参数为nil。查看this代码。