Uninitialized constant using Twitter ruby gem

邮差的信 提交于 2020-01-15 03:00:26

问题


In my Rails 3 app I am attempting to display the tweets of users who have stored their twitter handle in my app as @profile.twitter. For each of those users I want to search their tweets with a specific hashtag. I'd like to perform the search in an action in my ProfilesController and load the tweets in a tabbed container.

I took a crack at the controller action but am getting uninitialized constant ProfilesController::Twitter. Can anyone help explain why? This is my first crack at fetching data like this. Below is my code.

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'

回答1:


As Logan noted above, I needed to restart my server.



来源:https://stackoverflow.com/questions/8529953/uninitialized-constant-using-twitter-ruby-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!