ruby on rails - Oembed tweet - twitter gem -
ruby on rails - Oembed tweet - twitter gem -
this terribly simple question can't figure out how render embedded tweet.
for simplicity, controller:
class tweetscontroller < applicationcontroller def index @tweet = twitter_client.oembed('527501479142109184') end end
and in view if next displays object only:
<%= @tweet %>
i.e. #<twitter::oembed:0x007fb878abc5d8>
on inspection gives:
#<twitter::oembed:0x007fb875cacd28 @attrs={:cache_age=>"3153600000", :url=>"https://twitter.com/huayuansong/statuses/527501479142109184", :height=>nil, :provider_url=>"https://twitter.com", :provider_name=>"twitter", :author_name=>"huayuan song", :version=>"1.0", :author_url=>"https://twitter.com/huayuansong", :type=>"rich", :html=>"<blockquote class=\"twitter-tweet\"><p>jeg kunne lide en video på <a href=\"https://twitter.com/youtube\">@youtube</a> <a href=\"http://t.co/hhhtvyja6y\">http://t.co/hhhtvyja6y</a> obama: u.s. leading way against ebola spread</p>— huayuan song (@huayuansong) <a href=\"https://twitter.com/huayuansong/status/527501479142109184\">october 29, 2014</a></blockquote>\n<script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>", :width=>550}>
obviously, terribly simple , i'm using proof of concept type thing. can explain how go having object beingness able display actual embedded tweet?
thanks
simply calling @tweet
reference object. in order display tweet want call:
<%= raw(@tweet.html) %>
also, twitter's documentation:
the returned html snippet automatically recognized embedded tweet when twitter’s widget javascript included on page.
the javascript snippet looks this:
<script> window.twttr = (function (d, s, id) { var t, js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src= "https://platform.twitter.com/widgets.js"; fjs.parentnode.insertbefore(js, fjs); homecoming window.twttr || (t = { _e: [], ready: function (f) { t._e.push(f) } }); }(document, "script", "twitter-wjs")); </script>
ruby-on-rails twitter oembed twitter-gem
Comments
Post a Comment