简体   繁体   中英

cant find spreadsheet on GoogleDrive which was created by google_drive gem / learn-rails tutorial

I'm trying to complete the learn-rails tutorial and I have come across a problem implementing the writing of visitors recording in a GoogleDrive spreadsheet as depicted in the tutorial which actually refers to outdated procedures of loggging to the GoogleDrive spreadsheet.

Since userID / password are'nt supported anymore I created a service account at Google as suggested by the google_drive gem docs and succesfully connected from rails to my spreadsheet this way:

def update_spreadsheet connection = GoogleDrive::Session.from_service_account_key("SpreadSheet-acd8a78038a0.json") ss = connection.spreadsheet_by_title('Learn-Rails-Example') if ss.nil? ss = connection.create_spreadsheet('Learn-Rails-Example') end ws = ss.worksheets[0] last_row = 1 + ws.num_rows ws[last_row,1] = Time.new ws[last_row,2] = self.name ws[last_row,3] = self.email ws[last_row,4] = self.content puts "Current num rows: "+last_row.to_s ws.save end

Everythig runs fine in my rails app but I can't access the spreadsheet from GoogleDrive in my Chrome browser despite the fact that the spreadsheet actually exists somwhere since I noticed num_rows increrements at console log each time I add a contact within the app.

If I can't see the spreadsheet directly in Google Drive from Chrome then it's bad news since I'd need to write a separete ruby app to download the data.

Any suggestion is very welcome.

At last I found the solution:

1) I created a Learn-Rails-Example spreadsheet (it was the name given by rails) manually in my google drive

2) I shared that doc with the client_email of my service account (webserve@spreadsheet-61909.iam.gserviceaccount.com)

3) I Lunched the rails app and noticed that from now on the spreadsheet was update and visible to google drive in Chrome browser.

Problem solved!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM