Sha256: 72433ad2e197c0c9e812fc04d0b15a96a8751e6f501fcc81680fbd09dae14d25
Contents?: true
Size: 531 Bytes
Versions: 36
Compression:
Stored size: 531 Bytes
Contents
module ActiveadminSelleoCms class RelatedItem < ActiveRecord::Base attr_protected :id belongs_to :relatable, polymorphic: true belongs_to :page validates_presence_of :page_id, if: ->(ri){ ri.related_url.blank? } validates :related_url, presence: true, format: { with: /^http/i }, if: ->(ri){ ri.page_id.blank? } def target_title title.present? ? title : (page.present? ? page.title : related_url) end def target_url related_url.present? ? related_url : page.url end end end
Version data entries
36 entries across 36 versions & 1 rubygems