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.
21 lines
467 B
Ruby
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
|