Sha256: d24ad817bae76f26c0f5fcaa4e4cc7d05bd0b11490145facd28c864809139f8f
Contents?: true
Size: 666 Bytes
Versions: 7
Compression:
Stored size: 666 Bytes
Contents
module Storytime class Link < ActiveRecord::Base belongs_to :navigation, class_name: "Storytime::Navigation" belongs_to :linkable, polymorphic: true acts_as_list scope: :storytime_navigation_id default_scope { order(:position) } validates_presence_of :text validates_presence_of :url, if: Proc.new {|link| link.linkable.blank? } validates_presence_of :linkable, if: Proc.new {|link| link.url.blank? } before_save :ensure_protocol_for_external_links def ensure_protocol_for_external_links if linkable.blank? && url.present? && !url.include?("://") self.url = "http://#{url}" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems