2011-12-23 8 views
1

私は、キーワードを投稿して検索することができ、なぜそれが機能していないのかわからない、私は1000のものを変更し、エラーは、これは私のコントローラファイルTwitterの宝石でエラーが発生しました

def hello 
    @time = Time.now 

def user_tweet 
     require "rubygems" 
     require "twitter" 

    # Certain methods require authentication. To get your Twitter OAuth credentials, 
    # register an app at http://dev.twitter.com/apps 
    Twitter.configure do |config| 
     config.consumer_key  = 'xxxx' 
     config.consumer_secret = 'xxxx' 
     config.oauth_token  = 'xxxx' 
     config.oauth_token_secret = 'xxxx' 
    end 

    # Initialize your Twitter client 
    client = Twitter::Client.new 
    # Post a status update 
    client.update("updated tweet") 
    redirect_to request.referer, :notice => 'Tweet successfully posted' 
    end 

エンド

であり、これは私の見解ページ最後

<%= form_for (@tweet = Tweet.new, :url => user_tweet_path) do |tweet_form| 
tweet_form.text_area :tweet_content, :id => "tweet" 
tweet_form.submit "Tweet" 
end %> 

で、ここで私は取得していますエラーです:

構文エラー、予期しない「」、期待 『)』

私はちょうどビューファイルに<%= client.update("updated tweet")%>を入れてみましたが、それは未定義の変数エラーが発生した、私はレールに新たなんだ、そう任意のヘルプありがとう、ありがとう。

+0

そのエラーのスタックトレースがありますか? – rkb

答えて

0

(あなたがそれを必要としない)スタイルのために、(上記form_forのように)括弧の後にスペースを入れないでください、すべての行の後、あなたのERBタグを閉じて@tweetに値をASSINGません。

<%= form_for(Tweet.new, :url => user_tweet_path) do |tweet_form| %>    
    <%= tweet_form.text_area :tweet_content, :id => "tweet" %> 
    <%= tweet_form.submit "Tweet" %> 
<% end %> 
+0

ヒントをお寄せいただきありがとうございます。私のコントローラで見ることができるように、「クライアント= Twitter :: Client.new」で初期化されていますが、「初期化されていない定数ActionView :: CompiledTemplates :: Tweet」と表示されます。行方不明、どんなアイデア? – user1112641

+0

これは、Tweetと呼ばれるモデルを持っていないことを意味しています。したがって、form_forでテンプレートで使用する前に作成する必要があります。 –

関連する問題