2
在我的Rails 3應用程序中,我試圖顯示用戶在我的應用程序中存儲其嘰嘰喳喳句柄的用戶的推文,內容爲@profile.twitter
。對於這些用戶中的每一個,我都想用特定的標籤搜索他們的推文。我想在我的ProfilesController
中的某個操作中執行搜索,並在標籤容器中加載推文。未初始化的常量使用Twitter的紅寶石寶石
我在控制器操作上做了一個破解,但得到uninitialized constant ProfilesController::Twitter
。誰能幫助解釋爲什麼?這是我第一次獲取像這樣的數據。以下是我的代碼。
profiles_controller.rb:
def profile_tweets
@profile = Profile.find(params[:id])
@profile.tweets = Twitter.search("#hashtag", "from:#{@profile.twitter}")
render :json => @tweets
end
的routes.rb:
resources :profiles do
get :profile_about, :on => :member
get :profile_tweets, :on => :member
end
_profile_tweets.html.erb:
<% @tweets.each do |tweet| %>
<div class="question">
<div class="header">
<p class="body"><%= tweet.text %></p>
</div>
</div>
<% end %>
profile_tweets.js.erb:
$("#tabs-1").html("<%= escape_javascript(render(:partial => "profile_tweets"))%>");
的Gemfile:
gem 'twitter'
出於好奇,你是否確保捆綁並重新啓動服務器?在安裝新的gem之後,我沒有看到這個錯誤,而沒有重新啓動服務器。 – 2011-12-16 15:34:16