Skip to content
Adds video URL validation and API integration for using Vimeo on ActiveRecord models
Find file
Pull request Compare This branch is 1 commit ahead, 4 commits behind engageis:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Has Vimeo Video

Validate a Vimeo URL attribute in Active Record, and retrieve access to the video's data through Vimeo API.

This repo has been transfered to engageis

The oficial repo is now please update your local repositories.


Add to your Gemfile and run the bundle command to install it.

 gem "has_vimeo_video"

Requires Ruby 1.9.2 or later, and Rails 3.0.0 or later.


Call has_vimeo_video in an ActiveRecord class and pass the name of the attribute that will contain the URL for the video on Vimeo, e.g.

  class Post < ActiveRecord::Base
    has_vimeo_video :video_url

This will automatically validate the format of the URL to match Vimeo's, and will add a vimeo object to your model, which will contain the following methods:

  • info will give you access to a hash with the parsed response from Vimeo API
  • id will parse the id of the video from the URL (no API requests here)
  • embed_url will return a URL ready for embedding your video (no API requests as well)
  • thumbnail will return the URL for the large thumbnail from Vimeo API (the same as info['thumbnail_large'])

    post = Post.create video_url: '' # {"id"=>32733074, "title"=>"Belo Monte, Anúncio de uma Guerra (CATARSE)", "description"=>"Mais do que um filme, queremos que esse documentário seja um ato político da sociedade, uma luta pelo acesso à informação e pelo direito de participar das decisões do país.<br />\n<br />\nEntre em, assista o vídeo e apoie essa causa.", "url"=>"", "upload_date"=>"2011-11-27 06:49:45", "mobile_url"=>"", "thumbnail_small"=>"", "thumbnail_medium"=>"", "thumbnail_large"=>"", "user_name"=>"André Vilela D'Elia", "user_url"=>"", "user_portrait_small"=>"", "user_portrait_medium"=>"", "user_portrait_large"=>"", "user_portrait_huge"=>"", "stats_number_of_likes"=>221, "stats_number_of_plays"=>107330, "stats_number_of_comments"=>49, "duration"=>661, "width"=>640, "height"=>360, "tags"=>"belo, monte, anúncio, cinedelia, gota, guerra, catarse, indigenas, xingu, rio, river, raoni, kayapo, vivo, eletro, norte, felicio, pontes, pare, amazonia", "embed_privacy"=>"anywhere"} # 32733074
    post.vimeo.embed_url #
    post.vimeo.thumbnail #

Customizing validation message

You can customize the ActiveRecord validation message by passing the message option to has_vimeo_video.

  class Post < ActiveRecord::Base
    has_vimeo_video :video_url, message: "only Vimeo URLs are allowed"


Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

This gem is created by Engage and is under the MIT License.

Something went wrong with that request. Please try again.