Module: Decidim::Initiatives::InitiativeSlug

Included in:
Decidim::Initiative, Admin::InitiativeAdmin, CurrentInitiative, InitiativesController
Defined in:
lib/decidim/initiatives/initiative_slug.rb

Instance Method Summary collapse

Instance Method Details

#id_from_slug(slug) ⇒ Object



10
11
12
13
14
# File 'lib/decidim/initiatives/initiative_slug.rb', line 10

def id_from_slug(slug)
  return slug if /\A\d+\Z/.match?(slug)

  slug[2..-1] if slug.present?
end

#slug_from_id(id) ⇒ Object



6
7
8
# File 'lib/decidim/initiatives/initiative_slug.rb', line 6

def slug_from_id(id)
  "i-#{id}"
end