Sha256: f641a070db3ef3fad3d4dc3663f9ddd99395b1a2a9f5b0b96b4b89236cab6fbc
Contents?: true
Size: 603 Bytes
Versions: 1
Compression:
Stored size: 603 Bytes
Contents
module BcmsBitly module PageExtender def self.included(model) model.after_save :bcms_bitly_create_short_link model.has_one :short_link, class_name: 'BcmsBitly::ShortLink' def bcms_bitly_create_short_link if persisted? return unless path_changed? end domain = Rails.configuration.cms.site_domain sl = short_link || build_short_link sl.url = sl.shorten("http://#{domain}#{path}") sl.name = name self.short_link = sl self.short_link.save! self.short_link.publish! end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bcms_bitly-1.0.0 | lib/bcms_bitly/page_extender.rb |