문제

so I've been playing around with the youtube_it gem. The problem is that when I want to display thumbnails it comes out with weird codes like @height445 @width etc. I was wondering what can I do to make the actual pictures display in the table?

Thanks all!

This is the code that it displays when viewing the page.

<YouTubeIt::Model::Thumbnail:0x3feb470 @url="http://i.ytimg.com/vi/X_C_9xZYWNw/mqdefault.jpg", @height=180, @width=320, @time=nil, @name="mqdefault">, #<YouTubeIt::Model::Thumbnail:0x3feb020 @url="http://i.ytimg.com/vi/X_C_9xZYWNw/hqdefault.jpg", @height=360, @width=480, @time=nil, @name="hqdefault">, #<YouTubeIt::Model::Thumbnail:0x3fea9a8 @url="http://i.ytimg.com/vi/X_C_9xZYWNw/1.jpg", @height=90, @width=120, @time="00:01:00.250", @name="start">, #<YouTubeIt::Model::Thumbnail:0x3fea5b8 @url="http://i.ytimg.com/vi/X_C_9xZYWNw/2.jpg", @height=90, @width=120, @time="00:02:00.500", @name="middle">, #<YouTubeIt::Model::Thumbnail:0x3fea288 @url="http://i.ytimg.com/vi/X_C_9xZYWNw/3.jpg", @height=90, @width=120, @time="00:03:00.750", @name="end">]
도움이 되었습니까?

해결책

Those 'weird codes' are just graphical representations of ruby objects. It looks like what you have there is an array of thumbnail objects, so if you want to display them as html images you need to do something like this (this code goes in your .erb file):

<% @thumbnails.each do |thumbnail| %>
    <%= image_tag(thumbnail.url) %>
<% end %>

That will just render the image tags one after the other, which probably isn't what you want, but it should give you the idea.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top