Files
nairobi/app/models/widget/card.rb
Javi Martín ee29ca43a5 Make widget cards polymorphic
So now we'll be able to add them to other sections.

We're also adding a `dependent: :destroy` relation to models having
cards since it doesn't make sense to have cards around when their page
has been destroyed.
2021-01-14 17:37:58 +01:00

21 lines
467 B
Ruby

class Widget::Card < ApplicationRecord
include Imageable
belongs_to :cardable, polymorphic: true
translates :label, touch: true
translates :title, touch: true
translates :description, touch: true
translates :link_text, touch: true
include Globalizable
validates_translation :title, presence: true
def self.header
where(header: true)
end
def self.body
where(header: false, cardable_id: nil).order(:created_at)
end
end