Sha256: 790b44d0d76b1c60f033a11dab8cc7550a135fe3c46d5f7a2b8fa59ea5909a45

Contents?: true

Size: 670 Bytes

Versions: 2

Compression:

Stored size: 670 Bytes

Contents

class Mingle::Instagram::Photo < ActiveRecord::Base
  has_many :hashtaggings, class_name: 'Mingle::Hashtagging', as: :hashtaggable, dependent: :destroy
  has_many :hashtags, through: :hashtaggings

  validates :link, :photo_id, :url, :user_handle, :user_image_url, presence: true

  scope :ordered, lambda { order('created_at ASC') }

  before_save :ensure_https_urls

  private

  def ensure_https_urls
    self.link = link.sub(/http:/, 'https:')
    self.url = url.sub(/http:/, 'https:')
    self.user_image_url = user_image_url.sub(%r(http://images\.ak\.instagram\.com),
                                              'https://distillery.s3.amazonaws.com')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mingle-0.1.1 app/models/mingle/instagram/photo.rb
mingle-0.1 app/models/mingle/instagram/photo.rb