Class: Comable::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Ransackable
Defined in:
app/models/comable/page.rb

Constant Summary collapse

PREVIEW_SESSION_KEY =
:preview_page

Instance Method Summary collapse

Instance Method Details

#default_slugObject



21
22
23
24
# File 'app/models/comable/page.rb', line 21

def default_slug
  id ||= self.class.maximum(:id).next
  "pages_#{id}"
end

#normalize_slug(string) ⇒ Object



26
27
28
# File 'app/models/comable/page.rb', line 26

def normalize_slug(string)
  normalize_friendly_id(string).presence || default_slug
end

#published?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/comable/page.rb', line 17

def published?
  published_at.present? && published_at <= Time.now
end