2012-10-22 22 views
1

這是我的代碼,按照'fusion_tables' gem documentation。顯然,我不會在此代碼中發佈我的用戶名和密碼。爲什麼使用Ruby gem'fusion_tables'創建Fusion Table時出現403錯誤?

require 'fusion_tables' 

@ft = GData::Client::FusionTables.new  
@ft.clientlogin(my_google_account_name, my_google_account_password) 

# Creating a new table 
columns = [ 
    { 
     :name=>"column_1", 
     :type=>'string' 
    }, 
    { 
     :name=>"column_2", 
     :type=>'number' 
    } 
] 

new_table = @ft.create_table "Ruby table",columns 

# Inserting rows 
data = [ 
    { 
    "column_1"=>"This is a string", 
    "column_2"=>100 
    } 
] 

new_table.insert data 

當我運行它,我得到這個錯誤:

<HEAD> 
<TITLE>User does not have permission to view the underlying data</TITLE> 
</HEAD> 
<BODY BGCOLOR="#FFFFFF" TEXT="#000000"> 
<H1>User does not have permission to view the underlying data</H1> 
<H2>Error 403</H2> 
</BODY> 
</HTML> 

我該如何解決這個問題?

回答

1

看起來像create_table method在創業板有點過時。

我試過上面的例子,和boris_bikes example provided in the fusion_tables gem repo。在調用create_table方法的行上都拋出Error 403User does not have permission to view the underlying data錯誤消息。

在上述例子中,引發此錯誤的行是:

new_table = @ft.create_table "Ruby table",columns 

的「Ruby_table」融合表雖然被創建。 (注意:該fusion_table寶石sanitizes the table name,即它替換在給定的名稱空間使用下劃線)

最有可能的谷歌融合表格API已經改變了這種寶石一點在最近的時代。我有opened a new issue on the repo;希望開發人員儘快回覆。 (或者如果時間允許,我會深入研究,找出原因,並提交補丁)

現在,我建議忽略錯誤並自表創建後繼續前進。

運行new_table = @ft.create_table "Ruby table",columns線後,繼續進行下面的步驟:

tables = @ft.show_tables 
new_table = tables.select{|t| t.name == "Ruby_table" }.first 

# Inserting rows 
data = [ 
{ 
    "column_1"=>"This is a string", 
    "column_2"=>100 
    } 
] 

new_table.insert data 

有了,你應該看到線的融合表顯示出來。

在我的生產應用程序之一,我們手動創建所需的融合表 - 與現有的數據表(其中有沒有API的支持,截至目前)合併,然後用truncate & insert方法來更新融合表數據。因此,無法以編程方式創建Fusion Table並沒有成爲我們面臨的重大問題。

+0

現在問題已經解決:https://github.com/tokumine/fusion_tables/issues/19 –

相關問題