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