app/models/tramway/landing/block.rb in tramway-landing-1.2 vs app/models/tramway/landing/block.rb in tramway-landing-1.2.1
- old
+ new
@@ -1,8 +1,6 @@
class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
- belongs_to :link_object, polymorphic: true
-
enumerize :block_type, in: [ :header, :footer, :page, :cards, :features, :contacts, :news, :link ]
enumerize :navbar_link, in: [ :exist, :not_exist ], default: :not_exist
enumerize :link_object_type, in: [ 'Tramway::SportSchool::Document' ]
mount_uploader :background, PhotoUploader
@@ -22,6 +20,10 @@
scope :on_main_page, -> { active.where(view_state: :published).order :position }
scope :with_navbar_link, -> { where navbar_link: :exist }
scope :header, -> { on_main_page.where(block_type: :header).first }
scope :footer, -> { on_main_page.where(block_type: :footer).first }
+
+ def link_object
+ link_object_type.constantize.find link_object_id
+ end
end