2011-10-12 21 views
0

我有一個用def創建的ruby控制器類。我正在使用休息客戶端來訪問網頁,如谷歌。基本上這是我的代碼忽略了有關創建以來的其他細節。Rest-Client在rails上的使用ruby

def create 
    RestClient.get 'http://google.com' 
    @smsclass = Smsclass.new(params[:smsclass]) 

    respond_to do |format| 
    if @smsclass.save 
    format.html { redirect_to RestClient.get 'http://google.com'} 
    format.html { redirect_to @smsclass, :notice => 'Smsclass was successfully created.' } 
    format.json { render :json => @smsclass, :status => :created, :location => @smsclass } 
    else 
    format.html { render :action => "new" } 
    format.json { render :json => @smsclass.errors, :status => :unprocessable_entity } 
    end 
end 

我也需要休息客戶端。讓我知道什麼是錯的。 Thakn你。

+0

對我來說這看起來很腥!在這個問題中有沒有你錯過的東西? –

+0

我不這麼認爲。然而。如果我使用這個charlysisto建議如果我只是使用重定向 - 它的作品。我的最終問題是使用rest-client發送發佈請求。因此我想首先得到工作。我的帖子爲RestClient.post'http://services.yyy.com/SMS/TXT/?wsvKey=_7iutVlqdDcyfjffptZ1',:from =>'yyy',:nested => {:to =>'07980760812'}但是這沒有用。它說沒有收到數據。 – CodeGeek123

回答

0

redirect_to遵循的網址不是該網址的'結果'。

只要做format.html { redirect_to 'http://google.com'}如果你想它在谷歌上。

+0

我不這麼認爲。然而。如果我使用這個charlysisto建議如果我只是使用重定向 - 它的作品。我的最終問題是使用rest-client發送發佈請求。因此我想首先得到工作。我的帖子爲RestClient.post'services.yyy.com/SMS/TXT/?wsvKey=_7iutVlqdDcyfjffptZ1';,:from =>'yyy',::nested => {:to =>'07980760812'}但這不起作用。它說沒有收到數據。 – CodeGeek123