Class: Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/page.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate_slug(title) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/models/page.rb', line 11

def self.generate_slug title
  # generate a slug
  slug = title.parameterize
  if Page.where(slug: slug).exists?
    slug_count = Page.where(slug: slug).count
    slug << '_' + (slug_count + 1).to_s
  end
  slug
end

Instance Method Details

#identifierObject



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

def identifier
  self.title
end