Sha256: 72250217cb2067ef33d9ed709475131a9953fc3dd7861c2ad21716be70f8b415
Contents?: true
Size: 626 Bytes
Versions: 2
Compression:
Stored size: 626 Bytes
Contents
require 'bitly' module BcmsBitly class ShortLink < ActiveRecord::Base acts_as_content_block belongs_to :page, class_name: 'Cms::Page' validates_presence_of :url # Turn a URL into a shorter Bitly URL # # url - A String URL # # Examples # # shorten('http://www.google.com') # # Returns the shortened URL String def shorten(url) Bitly.use_api_version_3 username = BcmsBitly::Engine.config.bitly_username api_key = BcmsBitly::Engine.config.bitly_api_key bitly = Bitly.new(username, api_key) bitly.shorten(url).short_url end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bcms_bitly-1.0.0 | app/models/bcms_bitly/short_link.rb |
bcms_bitly-0.0.4 | app/models/bcms_bitly/short_link.rb |