tvalent2
tvalent2

Reputation: 5009

Troubleshooting searching with the Twitter ruby gem

I'm trying to do a search for a user's tweets with a specific hashtag, where the user's twitter handle is defined by the twitter attribute on the Profile model (@profile.twitter).

Here is the action in my controller:

def profile_twitter
  @profile = Profile.find(params[:id])
  @profile_tweets = Twitter.search(["#hashtag"], [from:"#{@profile.twitter}"])
  render :json => @tweets
end

If I perform the search manually like below it works, although I get an Unexpected tRPAREN in my IDE:

@profile_tweets = Twitter.search("#hashtag", from:"username")

If I perform the search like the one below (using the twitter attribute) the Unexpected tRPAREN goes away, but I get (undefined method 'merge' for [{:from=>"username"}]:Array):

@profile_tweets = Twitter.search(["#hashtag"], [from:"#{@profile.twitter}"])

If I perform the search like the one below (still using the twitter attribute) I get an Unexpected tRPAREN in my IDE, I get /Users/Travis/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault and my server shuts down.

@profile_tweets = Twitter.search("#hashtag", from:"@profile.twitter")

Doing the search a bit differently seems to work at first but then shuts the server down with the same segmentation fault as above:

@profile_tweets = Twitter.search("#hashtag", from:"#{@profile.twitter}")

Has anyone else encountered this who might be able to help me with a solution?

Upvotes: 0

Views: 1059

Answers (1)

tvalent2
tvalent2

Reputation: 5009

For anyone else who may have this problem, I opened the issue on GitHub and got the solution from Erik Michaels-Ober:

@profile_tweets = Twitter.search("#hashtag from:#{@profile.twitter}")

Upvotes: 1

Related Questions