Skip to content

Instantly share code, notes, and snippets.

@kench
Created June 5, 2010 16:52
Show Gist options
  • Save kench/426776 to your computer and use it in GitHub Desktop.
Save kench/426776 to your computer and use it in GitHub Desktop.
##vimeo_videos_controller.rb
class VimeoVideosController < ApplicationController
before_filter :fetch_remote,
:only => [:index, :edit, :add]
before_filter :find_video,
:only => [:show, :edit, :destroy]
def index
@videos = Content::VimeoVideo.all
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @videos }
end
end
def show
@video = Content::VimeoVideo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @video }
end
end
def add
@video = Content::VimeoVideo.new(params[:content])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @video }
end
end
def edit
vimeo = Content::VimeoVideo::find(params[:id])
end
private
def find_video
@video = Content::VimeoVideo.find(params[:id])
end
def fetch_remote
@remote_videos = Vimeo::Simple::User.videos(Settings.vimeo_username)
end
end
## index.html.erb
<h1>VimeoVideos#index</h1>
<p>Find me in app/views/vimeo_videos/index.html.erb</p>
<h1>Listing added Vimeo videos</h1>
<table>
<tr>
<th>Title</th>
<th>Description</th>
<th>Creation date</th>
<th>Video ID</th>
</tr>
<% @videos.each do |video| %>
<tr>
<td><%=h video.title %></td>
<td><%=h video.description %></td>
<td><%=h video.creation_date %></td>
<td><%=h video.video_id %>
<td><%= link_to 'Show', content %></td>
<td><%= link_to 'Edit', edit_content_path(content) %></td>
<td><%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<h1>Listing remote Vimeo Videos</h1>
<table>
<tr>
<th>Title</th>
<th>Description</th>
<th>Creation date</th>
<th>Video ID</th>
</tr>
<% @remote_videos.each do |remote_video| %>
<tr>
<td><%=h remote_video.title %></td>
<td><%=h remote_video.description %></td>
<td><%=h remote_video.upload_date %></td>
<td><%=h remote_video.id %>
<td><%= link_to 'Show', content %></td>
<td><%= link_to 'Edit', edit_content_path(content) %></td>
<td><%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
## Error output
Showing app/views/vimeo_videos/index.html.erb where line #41 raised:
undefined method `title' for #<Hash:0x103f992b0>
Extracted source (around line #41):
38:
39: <% @remote_videos.each do |remote_video| %>
40: <tr>
41: <td><%=h remote_video.title %></td>
42: <td><%=h remote_video.description %></td>
43: <td><%=h remote_video.upload_date %></td>
44: <td><%=h remote_video.id %>
## Contents of remote_videos in IRB
>> require "vimeo"
=> true
>> remote_videos = Vimeo::Simple::User.videos("aubreybertin")
=> [{"duration"=>"192", "stats_number_of_plays"=>"6", "thumbnail_small"=>"http://ats.vimeo.com/654/356/65435686_100.jpg", "user_portrait_large"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_100.jpg", "title"=>"Silence is Golden", "stats_number_of_likes"=>"0", "user_portrait_small"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_30.jpg", "upload_date"=>"2010-05-16 17:53:20", "url"=>"http://vimeo.com/11791175", "tags"=>"Silence is Golden, Binghamton, Aubrey, Bertin", "user_url"=>"http://vimeo.com/aubreybertin", "id"=>"11791175", "stats_number_of_comments"=>0, "height"=>"480", "user_portrait_huge"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_300.jpg", "user_portrait_medium"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_75.jpg", "user_name"=>"Aubrey Bertin", "thumbnail_medium"=>"http://ats.vimeo.com/654/356/65435686_200.jpg", "description"=>"An examination of a space through closeups and natural sounds (although not necessarily in sync). <br />\n<br />\nCreated for <br />\nBinghamton University CINE 252- Video and Filmmaking I<br />\nby Aubrey Bertin 2008", "width"=>"640", "thumbnail_large"=>"http://ats.vimeo.com/654/356/65435686_640.jpg"}, {"duration"=>"413", "stats_number_of_plays"=>"48", "thumbnail_small"=>"http://ats.vimeo.com/644/628/64462804_100.jpg", "user_portrait_large"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_100.jpg", "title"=>"Close Calls", "stats_number_of_likes"=>"0", "user_portrait_small"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_30.jpg", "upload_date"=>"2010-05-11 12:48:32", "url"=>"http://vimeo.com/11658109", "tags"=>"Close Calls, Binghamton University, Senior Thesis, Aubrey Bertin", "user_url"=>"http://vimeo.com/aubreybertin", "id"=>"11658109", "stats_number_of_comments"=>0, "height"=>"240", "user_portrait_huge"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_300.jpg", "user_portrait_medium"=>"http://ps.vimeo.com.s3.amazonaws.com/546/546366_75.jpg", "user_name"=>"Aubrey Bertin", "thumbnail_medium"=>"http://ats.vimeo.com/644/628/64462804_200.jpg", "description"=>"Aubrey Bertin's Senior Thesis Project at Binghamton University.<br />\n<br />\nOriginally shown on VHS through a CRT monitor to depict the popular medium of the 90's. <br />\n<br />\nThe audio is a recollection of three memories from three different members of a family. The degradation of analog video reflects the degradation of the memories themselves.<br />\n<br />\nThe visual element is comprised of found footage which has a sense of memory in itself, but has been redirected for a new purpose. This also makes the film broader and more approachable by a general audience, rather than just a personal tale.<br />\n<br />\nMaturity, fear and uncertainty are heavily used themes throughout the film. In the first story the mother speaks to the child, in the second the sibling speaks to the child, and in the third the child gains a voice of his own and speaks to his father. This evolving relationship represents the maturing of the individual, and the fear in each story changes from fear for himself, fear for someone close, and fear for complete strangers emphasizes this idea.<br />\n<br />\nAt this point, facing graduation, at a time filled with uncertainty, this video is the expression of this energy, in the hope that this time will also one day be a memory of a \"Close Call.\"<br />\n<br />\nEnjoy, Aubrey Bertin 2010", "width"=>"320", "thumbnail_large"=>"http://ats.vimeo.com/644/628/64462804_640.jpg"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment