开发者

Twitter in ruby on rails helper

开发者 https://www.devze.com 2023-03-20 05:03 出处:网络
I want to include my tweets on my homepage. Currently I have a helper which looks like this: module WelcomesHelper

I want to include my tweets on my homepage. Currently I have a helper which looks like this:

module WelcomesHelper

 def recent_tweets(user)
   html = "<div>"
   Twitter.user_timeline(user).each do |tweet|
       html << '<span class="tweet">' << tweet.text << '</span>'
   end 
   html << "</div>"
 end

end

However, it can not find the twitter gem. If it require it from irb it works fine, but how do I include it开发者_运维技巧 in my rails app?


Assuming rails3 - add

gem 'Twitter'

to your Gemfile, run bundle and it should work in your application.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号